gpt4 book ai didi

windows-10-iot-core - UWP 应用程序中使用 Microsoft.Azure.Devices.Client 时出现异常

转载 作者:行者123 更新时间:2023-12-01 12:13:59 24 4
gpt4 key购买 nike

当我尝试使用 https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-csharp-csharp-twin-getstarted 中提到的代码时在 UWP 应用程序中,等待 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()}

最佳答案

我已经下载了您提供的解决方案。通过在解决方案属性中将目标的最低版本更改为 16299 可以解决此问题。可以引用here了解如何选择 UWP 版本。

Minimum Version. This sets the TargetPlatformMinVersion setting in your project file. It also determines the value of the TargetDeviceFamily@MinVersion attribute in your app package manifest. The value you choose specifies the minimum version of the UWP platform that your project can work with.

enter image description here

此外,您应该在 Capabilities 中选择 Private Networks(Client & Server) (Package.appxmanifest) 以允许您的应用程序访问 IoT 中心。

privateNetworkClientServer
On Windows, this provides access to a home or work network – the app can send information to or from your computer and other computers on the same network. On Windows Phone, provides the same access as internetClient or internetClientServer.

关于windows-10-iot-core - UWP 应用程序中使用 Microsoft.Azure.Devices.Client 时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49586292/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com