When 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?
#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
The string should be deserialized to the POCO.
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)
project.json contents:
{
"dependencies": {
"Newtonsoft.Json" : "10.0.2"
},
"frameworks": {
"netcoreapp1.1": {
}
}
}
Maybe a better question is why do you need to take a dependency on Newtonsoft...
Still the same issue. We took the dependency to force the version of Newtonsoft to the exact same one that serialized the data on the source side. Unnecessary, I know, but we were grasping at straws.
Also is core supported inside Azure Functions. Try net46 just to be on the safe side.
@khariq Azure Functions only supports the net46 target.
You may have problems with your external reference as .NET Standard 1.3 is the highest supported by the runtime. Just want to clarify your comment on top, though; are you sure your assembly is not targeting .NET Standard 1.1?
@fabiocav It is target .NetCore1.1 I changed the framework to 1.0 (which from my understanding is in 1.3?) and the error still occurs. I also deleted project.json to make sure the framework reference is gone.
This might be helpful:
https://docs.microsoft.com/en-us/dotnet/articles/standard/library#net-platforms-support
In order to use your assembly in functions, you need to target netstandard 1.3 (maximum). Or .NET Framework 4.6
@khariq fabio is suggesting you need to target net46 or netstandard up to 1.3.
@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.