PlatformNotsupportedException在Glazor WebAssembly中带有Azure IoT Hub

发布于 2025-02-01 10:53:55 字数 1999 浏览 3 评论 0原文

我正在探索大火WebAssembly。我正在移植WPF应用程序来评估功能。该应用程序正在连接到Azure IoT Hub实例。

这是似乎有问题的代码部分:

var iotHubConnectionStringBuilder = IotHubConnectionStringBuilder.Create("HostName=<iotHubConnectionString>");

var registryManager = RegistryManager.CreateFromConnectionString(iotHubConnectionStringBuilder.ToString());

当调用create fromConnectionsTring时,提出了以下例外:

Unhandled Exception:
       System.PlatformNotSupportedException: Operation is not supported on this platform.
          at System.Net.Http.SocketsHttpHandler.get_SslOptions()
          at Microsoft.Azure.Devices.HttpClientHelper.CreateDefaultHttpMessageHandler(IWebProxy webProxy, Uri baseUri, Int32 connectionLeaseTimeoutMilliseconds)
          at Microsoft.Azure.Devices.HttpClientHelper.CreateDefaultClient(IWebProxy webProxy, Uri baseUri, Int32 connectionLeaseTimeoutMilliseconds)
          at Microsoft.Azure.Devices.HttpClientHelper..ctor(Uri baseAddress, IAuthorizationHeaderProvider authenticationHeaderProvider, IReadOnlyDictionary`2 defaultErrorMapping, TimeSpan timeout, IWebProxy customHttpProxy, Int32 connectionLeaseTimeoutMilliseconds)
          at Microsoft.Azure.Devices.RegistryManager..ctor(IotHubConnectionProperties connectionProperties, HttpTransportSettings transportSettings)
          at Microsoft.Azure.Devices.RegistryManager.CreateFromConnectionString(String connectionString, HttpTransportSettings transportSettings)
          at Microsoft.Azure.Devices.RegistryManager.CreateFromConnectionString(String connectionString)

问题

为什么会丢弃此错误?如何将其修复?

更新

令人惊讶的是,i Encounter“> Encounter”> Encounter“>该程序的MAUI版本也有类似的问题

I am exploring Blazor Webassembly. I am porting a WPF application to evaluate the functionalities. The application is connecting to an Azure IoT Hub instance.

Here is the section of code that seems problematic:

var iotHubConnectionStringBuilder = IotHubConnectionStringBuilder.Create("HostName=<iotHubConnectionString>");

var registryManager = RegistryManager.CreateFromConnectionString(iotHubConnectionStringBuilder.ToString());

When calling CreateFromConnectionString, the following exception is thrown:

Unhandled Exception:
       System.PlatformNotSupportedException: Operation is not supported on this platform.
          at System.Net.Http.SocketsHttpHandler.get_SslOptions()
          at Microsoft.Azure.Devices.HttpClientHelper.CreateDefaultHttpMessageHandler(IWebProxy webProxy, Uri baseUri, Int32 connectionLeaseTimeoutMilliseconds)
          at Microsoft.Azure.Devices.HttpClientHelper.CreateDefaultClient(IWebProxy webProxy, Uri baseUri, Int32 connectionLeaseTimeoutMilliseconds)
          at Microsoft.Azure.Devices.HttpClientHelper..ctor(Uri baseAddress, IAuthorizationHeaderProvider authenticationHeaderProvider, IReadOnlyDictionary`2 defaultErrorMapping, TimeSpan timeout, IWebProxy customHttpProxy, Int32 connectionLeaseTimeoutMilliseconds)
          at Microsoft.Azure.Devices.RegistryManager..ctor(IotHubConnectionProperties connectionProperties, HttpTransportSettings transportSettings)
          at Microsoft.Azure.Devices.RegistryManager.CreateFromConnectionString(String connectionString, HttpTransportSettings transportSettings)
          at Microsoft.Azure.Devices.RegistryManager.CreateFromConnectionString(String connectionString)

Question

Why is this error thrown and how can it be fixed?

Update

Surprisingly, I encounter a similar issue in the MAUI version of the program as well.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文