コード例 #1
0
ファイル: Program.cs プロジェクト: cashcat/wcf-2
        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);
        }
コード例 #3
0
ファイル: Service1.cs プロジェクト: wisexie/WCFDemo
 protected override void OnStop()
 {
     server.Stop();
 }
コード例 #4
0
ファイル: Form1.cs プロジェクト: wisexie/WCFDemo
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     server.Stop();
 }