0

I have a Azure function(v1) which references a class library project(net46). I'm getting the following error while deserialising a json with in the class library.

Error resolving type specified in JSON 'Reporting.Services.CreationRequest, Reporting.Services'. Path '$type', line 1, position 103.

SchedulerService.cs (Part of class librray)

 public async Task QueueReport(IList<ReportJob> reportJobs)
        {
            ...
            var _serializerSetting = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All };
           reportCreationRequest = JsonConvert.DeserializeObject<ReportCreationRequest>(reportJob.JobQueueMessage, _serializerSetting);
            ...
        }

Stack Trace:

   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ResolveTypeName(JsonReader reader, Type& objectType, JsonContract& contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, String qualifiedTypeName)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadMetadataProperties(JsonReader reader, Type& objectType, JsonContract& contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue, Object& newValue, String& id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at Normandy.Portal.Reporting.Services.ReportingSchedulerV2.<QueueReportJobs>d__29.MoveNext() in C:\miis-source\Portal\src\Normandy.Portal.Reporting.Services\ReportingSchedulerV2.cs:line 436

Inner Exception: "Could not load assembly 'Reporting.Services'."

I have referenced this project in azure functions and also I can see this dll in Azure function's bin. But I still get this error. Any insights on this issue would be helpful.

PNDev
  • 590
  • 1
  • 8
  • 23
  • How did you create the function ? From visual studio or straight from the portal ? – HariHaran Oct 29 '19 at 04:46
  • @HariHaran From Visual Studio – PNDev Oct 29 '19 at 04:52
  • is the functions working fine on local ? The error message clearly states a missing reference. Try cleaning the solution and rebuild it. Remove the reference and re-add it. First check if its working fine in local. If yes-> What method are you using to deploy the function ? – HariHaran Oct 29 '19 at 04:54
  • I haven't deployed to cloud yet. I'm getting this issue in local. I tried cleaning and rebuilding the solution and tried removed and adding the reference. But no luck. – PNDev Oct 29 '19 at 04:55
  • What version of VS are you using ? Try closing VS and re-opening it as administrator – HariHaran Oct 29 '19 at 04:56
  • 1
    2017 and it's running with admin privileges. I'm restarting the machine to see if that helps. – PNDev Oct 29 '19 at 04:57
  • No luck with restarting machine. – PNDev Oct 29 '19 at 05:20
  • If you don't mind, you can deploy it to azure cloud and if it still shows the error "Could not load assembly 'Reporting.Services", you can import the .dll manually by following the steps in this [post](https://stackoverflow.com/questions/57966783/how-can-i-add-ssh-net-nuget-packages-into-my-azure-functions-v2-0/57966824#57966824). – Hury Shen Oct 29 '19 at 05:47
  • @HuryShen that din't work. Though the message say's it can't find the assembly, I can see the assembly in bin folder. – PNDev Oct 31 '19 at 02:43
  • Hi @PNDev , is your assembly in bin folder in ".dll" type ? – Hury Shen Oct 31 '19 at 02:47
  • @HuryShen yes it is. – PNDev Oct 31 '19 at 11:44

0 Answers0