【发布时间】:2018-09-10 04:41:37
【问题描述】:
当我尝试在 UWP 应用程序中使用 https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-csharp-csharp-twin-getstarted 中提到的代码时,等待 Client.GetTwinAsync();引发以下异常。 我在两台不同的机器上尝试过但同样的错误,即使调用 OpenAsync 也会导致同样的异常。我正在尝试创建 UWP 应用,以便可以将其部署在 IOT 设备上。
{System.IO.FileNotFoundException: Could not load file or assembly 'System.Net.Security, Version=4.0.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Net.Security, Version=4.0.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at Microsoft.Azure.Devices.Client.DeviceClient.<>c.b__74_2(Task t)
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.TaskAwaiter.GetResult()
at AzureIoTSuiteUWPDevice.MainPage.d__34.MoveNext()}
【问题讨论】:
-
您的 IoT 设备上运行的是什么版本?您选择了哪个版本的 Microsoft.Azure.Devices.Client?
-
我还没有将它部署到物联网设备上,因为我仍在尝试让它在我的开发机器(Windows 10 1709.16299)上运行。 Microsoft.Azure.Devices.Client 1.7.0 Microsoft.Azure.Devices.Shared 1.5.0 Microsoft.NETCore.UniversalWindowsPlatform 6.0.8
-
您是否在解决方案中添加了一些其他包?请检查 System.Net.Security4.0.1 是否存在包依赖项。实际上,Microsoft.Azure.Devices.Client 1.7.0 依赖于 System.Net.Security4.3.2。也许您的解决方案中存在一些冲突。
-
不,这些是我在项目中引用的唯一包。
-
这里是link 用于复制的简单解决方案。