BlazorAssembly 注入NacosV2Naming 时报异常:PlatformNotSupportedException异常?

我在尝试使用BlazorWebAssembly作为客户端,到Nacos去获取服务。但是碰到了下面的错误:

System.PlatformNotSupportedException: Cannot wait on monitors on this runtime.
   at System.Threading.Monitor.ObjWait(Int32 millisecondsTimeout, Object obj)
   at System.Threading.Monitor.Wait(Object obj, Int32 millisecondsTimeout)
   at System.Threading.ManualResetEventSlim.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.SpinThenBlockingWait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.InternalWaitCore(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.InternalWait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at Nacos.V2.Naming.Remote.NamingClientProxyDelegate.InitSecurityProxy()
   at Nacos.V2.Naming.Remote.NamingClientProxyDelegate..ctor(ILogger logger, String namespace, ServiceInfoHolder serviceInfoHolder, NacosSdkOptions options, InstancesChangeNotifier changeNotifier, IHttpClientFactory clientFactory)
   at Nacos.V2.Naming.NacosNamingService..ctor(ILoggerFactory loggerFactory, IOptions`1 optionAccs, IHttpClientFactory clientFactory)

请问有大佬知道是啥原因嘛?
代码如下:
Program.cs:

// Nacos service
builder.Services.AddNacosV2Naming(serv =>
{
    serv.ServerAddresses = new List<string> { "http://localhost:8848/" };
    serv.EndPoint = "";
    serv.Namespace = "a76dac98-25c5-40c6-a57e-73904365dd1e";

    serv.ConfigUseRpc = true;
    serv.NamingUseRpc = true;
});

注入的service:

public event Action? OnChange;
private readonly ILocalStorageService _localStorageService;
private readonly HttpClient _httpClient;
private readonly INacosNamingService _nacosNamingService;

public CartService(ILocalStorageService localStorageService, HttpClient httpClient, INacosNamingService nacosNamingService)
{
    _localStorageService = localStorageService;
    _httpClient = httpClient;
    _nacosNamingService = nacosNamingService;
}

谢谢!

阅读 1.3k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏