public static async Task Main(string[] args) { try { // register IDebugService proxy generated by ServiceModel.Grpc.DesignTime DefaultClientFactory.AddDebugServiceClient(); var nativeChannel = new Channel("localhost", ServiceConfiguration.ServiceNativeGrpcPort, ChannelCredentials.Insecure); var serviceModelChannel = new Channel("localhost", ServiceConfiguration.ServiceModelGrpcPort, ChannelCredentials.Insecure); Console.WriteLine(); Console.WriteLine("Invoke ThrowApplicationException on ServerAspNetHost"); await InvokeThrowApplicationException(serviceModelChannel); Console.WriteLine(); Console.WriteLine("Invoke ThrowApplicationException on ServerNativeHost"); await InvokeThrowApplicationException(nativeChannel); Console.WriteLine(); Console.WriteLine("Invoke ThrowRandomException on ServerAspNetHost"); await InvokeThrowRandomException(serviceModelChannel); Console.WriteLine(); Console.WriteLine("Invoke ThrowRandomException on ServerNativeHost"); await InvokeThrowRandomException(nativeChannel); } catch (Exception ex) { Console.WriteLine(ex); } Console.WriteLine("..."); Console.ReadLine(); }
public static async Task Main() { var aspNetCoreChannel = new Channel("localhost", SharedConfiguration.AspNetgRPCDebugServicePort, ChannelCredentials.Insecure); // register IDebugService proxy generated by ServiceModel.Grpc.DesignTime DefaultClientFactory.AddDebugServiceClient(); var proxy = DefaultClientFactory.CreateClient <IDebugService>(aspNetCoreChannel); Console.WriteLine("-- call AspNetServiceHost --"); await CallThrowApplicationException(proxy); await CallThrowInvalidOperationException(proxy); var nativeChannel = new Channel("localhost", SharedConfiguration.NativegRPCDebugServicePort, ChannelCredentials.Insecure); proxy = DefaultClientFactory.CreateClient <IDebugService>(nativeChannel); Console.WriteLine(); Console.WriteLine("-- call NativeServiceHost --"); await CallThrowApplicationException(proxy); await CallThrowInvalidOperationException(proxy); Console.WriteLine("..."); Console.ReadLine(); }