예제 #1
0
 public void CreateMultipleChannelProxies()
 {
     string address = "net.pipe://localhost/";
     using (ServiceHost<TestService> host = new ServiceHost<TestService>())
     {
         host.AddServiceEndpoint<ITestContract>(new NetNamedPipeBinding(), address);
         host.Open();
         ITestContract proxy1 = host.CreateChannel<ITestContract>(new NetNamedPipeBinding(), address);
         ITestContract proxy2 = host.CreateChannel<ITestContract>(new NetNamedPipeBinding(), address);
         Assert.AreNotSame(proxy1, proxy2);
         Assert.AreEqual<string>("MyResult", proxy1.MyOperation());
         Assert.AreEqual<string>("MyResult", proxy2.MyOperation());
         ((ICommunicationObject)proxy1).Close();
         ((ICommunicationObject)proxy2).Close();
     }
 }