Azure Functions: Exception while executing function: unable to find assembly 'System.Runtime, Version=4.1.0.0'
See original GitHub issueWhen attempting to use JsonConvert to deserialize a Service Bus message to a domain POCO, the following exception is through:
Unable to find assembly ‘System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’. Are you missing a private assembly file?
Repro steps
#r "Newtonsoft.Json"
// Entities.dll is a netcoreapp1.1 assembly that defines our business POCOs
#r "Entities.dll"
using System;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Entities.Messages;
public static string Run(byte[] evaluationRequest, TraceWriter log)
{
var body = System.Text.Encoding.UTF8.GetString(evaluationRequest);
log.Info($"C# ServiceBus queue trigger function processed message: {body}");
try
{
// EvaluationRequest is defined in Entities.dll in the Entities.Messages namespace
// commenting this line out prints the log message
var message = JsonConvert.DeserializeObject<EvaluationRequest>(body);
}
catch (Exception ex)
{
log.Info($"Bad invocation {ex.Message}");
}
return "200";
}
// Bringing the Object Graph into a types.csx file and loading it results in a successful deserialization
// POCO from Entities.dll
public class EvaluationRequest
{
// Standard System.Guid
public Guid Measure { get; set; }
// Another object in the Entities DLL
public Patient Patient { get; set; }
// An Enum
public Application ApplicationId { get; set; }
public string ClientId { get; set; }
}
Provide the steps required to reproduce the problem
- Create the function above
- Comment out the body of the try…catch block
- Execute function and the function succeeds and the log message is printed.
- Uncomment the try…catch block
- Execute the function and the exception is thrown, but no log message is printed (this makes us think it has something to do with the JIT compiler).
Expected behavior
The string should be deserialized to the POCO.
Actual behavior
2017-05-16T18:51:10.477 Function started (Id=21f3f001-cab2-49ff-84b7-d531a5d667a5) 2017-05-16T18:51:10.477 Unable to find assembly ‘System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’. Are you missing a private assembly file? 2017-05-16T18:51:10.477 Function completed (Failure, Id=21f3f001-cab2-49ff-84b7-d531a5d667a5, Duration=2ms)
Related information
project.json contents:
{
"dependencies": {
"Newtonsoft.Json" : "10.0.2"
},
"frameworks": {
"netcoreapp1.1": {
}
}
}
- Programming language used C#, .csx, Azure Functions
- Links to source
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (2 by maintainers)
Top GitHub Comments
@fabiocav @dallancarr Thank you both your patient explanations. I’ve changed my assemblies to target .Net Standard 1.3 on build. I was convinced you were talking about changing the project.json file.
@khariq fabio is suggesting you need to target net46 or netstandard up to 1.3.