Azure / azure-iot-sdk-csharp

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

Exception when trying to send Device Message #630

Closed ghost closed 6 years ago

ghost commented 6 years ago

Steps:

  1. Create new .Net 4.7.1 project
  2. Install nuget from nuget.org Microsoft.Azure.Devices.Client 1.18.0
  3. Update all the nugets in project
  4. Copy code from Iot Hub sample (update Iot Hub DeviceConnectionString) here
  5. Run

Actual result: _DotNetty.Transport.Channels.ClosedChannelException: I/O error occurred. at Microsoft.Azure.Devices.Client.InternalClient.<>c.b__622(Task t) at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke() at System.Threading.Tasks.Task.Execute()

Note, that the same code executed directly from the sample (.Net Core + Microsoft.Azure.Devices.Client 1.0.0 ) works fine.

CIPop commented 6 years ago

@VladVladovich step 3 might have updated the Devices.Client dependencies to something that we don't support. Also, please use the samples from here instead: https://github.com/Azure-Samples/azure-iot-samples-csharp

ghost commented 6 years ago

@CIPop , in this case I have another issue Steps:

  1. Create new .Net 4.7.1 project
  2. Install nuget from nuget.org Microsoft.Azure.Devices.Client 1.18.0
  3. Copy Program and MessageSample classes from Iot Hub sample here
  4. Run

Result: System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.'

Inner exception FileNotFoundException: Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Stack

   at Microsoft.Azure.Devices.Client.InternalClient.<>c.<ApplyTimeout>b__62_2(Task t)
   at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
   at Microsoft.Azure.Devices.Client.Samples.MessageSample.<SendEvent>d__8.MoveNext() in C:\Projects\Console\ConsoleApp1\MessageSample.cs:line 45
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
   at Microsoft.Azure.Devices.Client.Samples.MessageSample.<RunSampleAsync>d__7.MoveNext() in C:\Projects\Console\ConsoleApp1\MessageSample.cs:line 26
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Microsoft.Azure.Devices.Client.Samples.Program.Main(String[] args) in C:\Projects\Console\ConsoleApp1\Program.cs:line 43

Probably, some dependencies are missing in Microsoft.Azure.Devices.Client nuget nuspec

ghost commented 6 years ago

I tried to remove all the automatically generated binding redirects from config and currently it works

az-iot-builder-01 commented 6 years ago

@VladVladovich, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey