static void Main(string[] args) { string filename = AppDomain.CurrentDomain.BaseDirectory + "config\\catclient.xml"; Cat.Initialize(filename); WcfServer server = WcfServer.GetInstance(); server.WcfFaultedEvent += new WcfFaulted(server_WcfFaultedEvent); server.WcfClosedEvent += new WcfClosed(server_WcfClosedEvent); server.WcfBeforeCallEvent += new WcfBeforeCall(server_WcfBeforeCallEvent); server.WcfAfterCallEvent += new WcfAfterCall(server_WcfAfterCallEvent); server.Start(); Console.WriteLine("服务启动..."); Console.ReadKey(); server.Stop(); }
public void Calling_dispose_on_a_WcfClient_should_not_throw_EndpointNotFoundException() { // start the server var wcfServer = new WcfServer(); wcfServer.Start(); // create the client and test it var client = new WcfClient(new WcfChannel <IMessageProcessor>(wcfServer.EndpointAddress), "testclient"); Assert.DoesNotThrow(() => { var response = client.EchoMessage("teszt"); Assert.IsInstanceOf <EchoResponse>(response); Assert.That(((EchoResponse)response).Message, Is.StringContaining("Echo: teszt")); }); // now stop the server and dispose the client and check if it throws wcfServer.Stop(); Assert.DoesNotThrow(client.Dispose); }
protected override void OnStop() { server.Stop(); }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { server.Stop(); }