Azure / azure-functions-host

The host/runtime that powers Azure Functions
https://functions.azure.com
MIT License
1.93k stars 441 forks source link

Runtime error in azure function for System.Runtime.CompilerServices.Unsafe #3901

Open apt-rider opened 5 years ago

apt-rider commented 5 years ago

Hi,

I am using Microsoft.Azure.Devices.Client": "1.18.1" in my Azure Function on V1. First I got error for assembly "DotNetty.Common": "0.6.0.0". I tried to add this assembly reference explicitly in my project.json and the error got resolved. Now I am getting error for assembly "System.Runtime.CompilerServices.Unsafe": "4.0.4.1". I have tried to explicitly add its reference too in my project.json, however it still throws same error on method call UpdateReportedPropertiesAsync().

My project.json; { "frameworks": { "net46":{ "dependencies": { "Microsoft.Azure.Devices.Client": "1.18.1", "Microsoft.Azure.Devices.Shared": "1.15.1", "DotNetty.Common": "0.6.0.0", "System.Runtime.CompilerServices.Unsafe": "4.0.4.1" } } } }

Error log; 2018-12-17T15:43:09.035 [Warning] Unable to find assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Are you missing a private assembly file? 2018-12-17T15:43:09.051 [Warning] Unable to find assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Are you missing a private assembly file? 2018-12-17T15:43:09.254 [Error] Exception while executing function: Functions.EventHubTriggerToIoTHubUpdateDeviceTwin. mscorlib: Exception has been thrown by the target of an invocation. mscorlib: One or more errors occurred. Microsoft.Azure.Devices.Client: I/O error occurred.

Expected behavior

Function should run with default assemblies loaded, or it should load assembly defined in project.json

Actual behavior

Function complies, but it throws run time errors


Client = DeviceClient.CreateFromConnectionString(DeviceConnectionString, TransportType.Mqtt);            TwinCollection reportedProperties = PrepareReportedProperties(myDevice);
Task taskUpdate = Client.UpdateReportedPropertiesAsync(reportedProperties);
apt-rider commented 5 years ago

Is it a known issue while trying to use Microsoft.Azure.Devices.Client? How can we use Microsoft.Azure.Devices.Client in our Azure functions?