System.ExecutionEngineException' 发生在 mscorlib.dll

问题描述

我正在尝试使用 C# 和服务结构在 .NET Framework 上运行一个简单的 Client Servier Communicaton 应用程序。对于服务间通信,我尝试使用 gRPC,并且我已将客户端和服务器作为集群上的单独服务.我正在使用可靠的服务 API 来覆盖功能并建立服务间通信。但是,当我运行代码时,出现此错误:-

Exception thrown: 'Grpc.Core.RpcException' in mscorlib.dll
Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in
 'C:\Users\Administrator\source\repos\TestGRPC\ClientService\bin\x64\Debug\ClientService.exe'.

Additional information: The runtime has encountered a Fatal error. The address of the error was at 0xeed5af27,on thread 0x578. The error code is 0x80131623.
This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code.
Common sources of this bug include user marshaling errors for COM-interop or PInvoke,which may corrupt the stack.
An unhandled exception of type 'System.ExecutionEngineException' occurred in mscorlib.dll

然后我找出了导致这个错误的那一行:-

static Random mRand = new Random();
        protected override async Task RunAsync(CancellationToken cancellationToken)
        {
            long iterations = 0;
            ServicePartitionResolver partitionResolver = new ServicePartitionResolver("localhost:19000");
            var partition = partitionResolver.ResolveAsync(new Uri("fabric:/TestGRPC/gRPCServer"),ServicePartitionKey.Singleton,new System.Threading.CancellationToken()).Result;
            var endpoint = partition.Endpoints.ElementAt(mRand.Next(0,partition.Endpoints.Count));

            var address = endpoint.Address.Substring(endpoint.Address.IndexOf("\"\":\"") + 4);
            address = address.Substring(0,address.IndexOf("\""));

            Channel channel = new Channel(address,ChannelCredentials.Insecure);
            var client = new AccountService.AccountServiceClient(channel);
            while (true)
            {
                cancellationToken.ThrowIfCancellationRequested();
                EmployeeName empName = client.GetEmployeeName(new EmployeeNameRequest { EmpId = "1" });
                if (empName == null || string.IsNullOrWhiteSpace(empName.FirstName) || string.IsNullOrWhiteSpace(empName.LastName))
                {
                    ServiceEventSource.Current.ServiceMessage(this.Context,"Emplyee Not found");
                    Console.WriteLine("Employee not found.");
                }
                else
                {
                    ServiceEventSource.Current.ServiceMessage(this.Context,"Emplyee Name: {0} {1}",empName.FirstName,empName.LastName);
                    Console.WriteLine($"The employee name is {empName.FirstName} {empName.LastName}.");
                }
                ServiceEventSource.Current.ServiceMessage(this.Context,"Working-{0}",++iterations);

                await Task.Delay(TimeSpan.FromSeconds(1),cancellationToken);
            }
        }

是线

EmployeeName empName = client.GetEmployeeName(new EmployeeNameRequest { EmpId = "1" });

我怀疑域名没有被正确解析,或者我不知道如何生成正确的域名地址。警告消息中也有同样的指示。服务器似乎在集群上运行良好。 集群上显示的警告消息以及堆栈跟踪是:-

'RunAsync' reported Warning for property 'RunAsyncUnhandledException'.
Grpc.Core.RpcException: Status(StatusCode="Unavailable",Detail="DNS resolution Failed for service: MININT-H7Q1KHO:50001",DebugException="Grpc.Core.Internal.CoreErrorDetailException: {"created":"@1624221009.546000000","description":"Resolver transient failure","file":"..\..\..\src\core\ext\filters\client_channel\client_channel.cc","file_line":1361,"referenced_errors":[{"created":"@1624221009.546000000","description":"DNS resolution Failed for service: MININT-H7Q1KHO:50001","file":"..\..\..\src\core\ext\filters\client_channel\resolver\dns\c_ares\dns_resolver_ares.cc","file_line":362,"grpc_status":14,"referenced_errors":[{"created":"@1624221009.545000000","description":"C-ares status is not ARES_SUCCESS qtype=A name=MININT-H7Q1KHO is_balancer=0: Domain name not found","file":"..\..\..\src\core\ext\filters\client_channel\resolver\dns\c_ares\grpc_ares_wrapper.cc","file_line":724,"description":"C-ares status is not ARES_SUCCESS qtype=AAAA name=MININT-H7Q1KHO is_balancer=0: Domain name not found","file_line":724}]}]}]}")
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Grpc.Core.Internal.AsyncCall`2.UnaryCall(TRequest msg) in /var/local/git/grpc/src/csharp/Grpc.Core/Internal/AsyncCall.cs:line 78
   at Grpc.Core.DefaultCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2 method,String host,CallOptions options,TRequest request) in /var/local/git/grpc/src/csharp/Grpc.Core/DefaultCallInvoker.cs:line 46
   at Grpc.Core.Interceptors.InterceptingCallInvoker.<BlockingUnaryCall>b__3_0[TRequest,TResponse](TRequest req,ClientInterceptorContext`2 ctx) in /var/local/git/grpc/src/csharp/Grpc.Core.Api/Interceptors/InterceptingCallInvoker.cs:line 51
   at Grpc.Core.ClientBase.ClientBaseConfiguration.ClientBaseConfigurationInterceptor.BlockingUnaryCall[TRequest,TResponse](TRequest request,ClientInterceptorContext`2 context,BlockingUnaryCallContinuation`2 continuation) in /var/local/git/grpc/src/csharp/Grpc.Core.Api/ClientBase.cs:line 174
   at Grpc.Core.Interceptors.InterceptingCallInvoker.BlockingUnaryCall[TRequest,TRequest request) in /var/local/git/grpc/src/csharp/Grpc.Core.Api/Interceptors/InterceptingCallInvoker.cs:line 48
   at AccountService.AccountServiceClient.GetEmployeeName(EmployeeNameRequest request,CallOptions options) in C:\Users\Administrator\source\repos\TestGRPC\ClientService\AccountGrpc.cs:line 100
   at AccountService.AccountServiceClient.GetEmployeeName(EmployeeNameRequest request,Metadata headers,Nullable`1 deadline,CancellationToken cancellationToken) in C:\Users\Administrator\source\repos\TestGRPC\ClientService\AccountGrpc.cs:line 96
   at ClientService.ClientService.<RunAsync>d__3.MoveNext() in C:\Users\Administrator\source\repos\TestGRPC\ClientService\ClientService.cs:line 56
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.ServiceFabric.Services.Runtime.StatelessServiceInstanceAdapter.<ExecuteRunAsync>d__18.MoveNext()

我被困在这个问题上很长时间了。我对SF有点陌生,不知道如何解决这个问题。任何帮助将不胜感激。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)