Azure / azure-iot-sdk-csharp

A C# SDK for connecting devices to Microsoft Azure IoT services
Other
466 stars 493 forks source link

Could not load file or assembly 1.6.0 for .NET Framework #275

Closed grtn316 closed 6 years ago

grtn316 commented 6 years ago

I tried updating the device client and am getting this error now:

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileLoadException: Could not load file or assembly 'DotNetty.Codecs.Mqtt, Version=0.4.7.0, Culture=neutral, PublicKeyToken=bc13ca065fa06c29'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) at Microsoft.Azure.Devices.Client.DeviceClient.CreateFromConnectionString(String connectionString, IAuthenticationMethod authenticationMethod, TransportType transportType, IDeviceClientPipelineBuilder pipelineBuilder)

Running .net core 2.0.

henrikstromberg commented 6 years ago

I get the same error. I event tries to add DotNetty.Codecs.Mqtt, Version=0.4.7.0 nuget my self. Running .net core 2.0.

adamkjonesmesh commented 6 years ago

I just pulled down and installed 1.6.0 and received the exact same error. Reverted back to 1.5.2 and everything works.

CIPop commented 6 years ago

Thanks for reporting @grtn316 and for confirming @henrikstromberg and @adamkjonesmesh . This should only happen for .NET Framework and not .NET Core / Standard. Looks like there's an issue with our NuSpec for .Net 4.6. As a workaround please manually reference the DotNetty.Codecs.Mqtt version=0.4.7.0 in your application.

The fix will come in 2 steps:

  1. Fix the nuspec and regenerate packages that correctly reference 0.4.7.
  2. Remove the multiple csproj files and build & package using the new dotnet pack command.
CIPop commented 6 years ago

Should be fixed by #308.