public void TestCppExceptions() { var server = GetErrorHandlingServer(); var serverInterface = (RPC_SERVER_INTERFACE)Marshal.PtrToStructure(server, typeof(RPC_SERVER_INTERFACE)); var endPointName = Implementer + DateTime.Now.Ticks + serverInterface.InterfaceId.SyntaxGUID.ToString("N"); var endpointBindingInfo = new EndpointBindingInfo(RpcProtseq.ncalrpc, null, endPointName); NativeHost.StartServer(endpointBindingInfo, server); RPC_STATUS status; var client = new NativeClient(endpointBindingInfo); CallErrorThrowingServer(client.Binding); }
public void TestCallback() { var server = GetExplicitWithCallbacksServer(); var endPointName =Implementer + DateTime.Now.Ticks; var serverInterface = (RPC_SERVER_INTERFACE)Marshal.PtrToStructure(server, typeof(RPC_SERVER_INTERFACE)); var endpointBindingInfo = new EndpointBindingInfo(RpcProtseq.ncalrpc, null, endPointName); NativeHost.StartServer(endpointBindingInfo, server); RPC_STATUS status; var client = new NativeClient(endpointBindingInfo); CallExplicitWithCallbacksServer(client.Binding); }
protected virtual void Dispose(bool disposing) { if (!disposing) { return; } if (this.drsConnection != null) { this.drsConnection.Dispose(); this.drsConnection = null; } if (this.rpcConnection != null) { this.rpcConnection.Dispose(); this.rpcConnection = null; } if(this.npConnection != null) { this.npConnection.Dispose(); this.npConnection = null; } }
private void CreateRpcConnection(string server, RpcProtocol protocol, NetworkCredential credential = null) { EndpointBindingInfo binding; switch(protocol) { case RpcProtocol.TCP: binding = new EndpointBindingInfo(RpcProtseq.ncacn_ip_tcp, server, null); break; case RpcProtocol.SMB: binding = new EndpointBindingInfo(RpcProtseq.ncacn_np, server, DrsNamedPipeName); if(credential != null) { // Connect named pipe this.npConnection = new NamedPipeConnection(server, credential); } break; default: // TODO: Custom exception type // TODO: Extract as string throw new Exception("Unsupported RPC protocol"); } NetworkCredential rpcCredential = credential ?? Client.Self; this.rpcConnection = new NativeClient(binding); this.rpcConnection.AuthenticateAs(rpcCredential); }
public void TestErrorsNoServerListening() { var endPointName = Implementer + DateTime.Now.Ticks; var endpointBindingInfo = new EndpointBindingInfo(RpcProtseq.ncalrpc, null, endPointName); var client = new NativeClient(endpointBindingInfo); CallErrorHandlingServer(client.Binding); }