本文整理汇总了C#中ChannelFactory类的典型用法代码示例。如果您正苦于以下问题:C#ChannelFactory类的具体用法?C#ChannelFactory怎么用?C#ChannelFactory使用的例子?这里精选的类代码示例或许可以为您提供帮助。
示例1:ServerAncClientExceptionsEndpointBehavior
publicvoidServerAncClientExceptionsEndpointBehavior()
{
varhook=newExceptionsEndpointBehaviour();
varaddress=@"net.pipe://127.0.0.1/test"+this.GetType().Name+"_"+MethodBase.GetCurrentMethod().Name;
varserv=newExceptionService();
using(varhost=newServiceHost(serv,newUri[]{newUri(address),}))
{
varb=newNetNamedPipeBinding();
varserverEndpoint=host.AddServiceEndpoint(typeof(IExceptionService),b,address);
serverEndpoint.Behaviors.Add(hook);
host.Open();
varf=newChannelFactory
(b);
f.Endpoint.Behaviors.Add(hook);
varc=f.CreateChannel(newEndpointAddress(address));
try
{
c.DoException("message");
}
catch(InvalidOperationExceptionex)
{
StringAssert.AreEqualIgnoringCase("message",ex.Message);
}
host.Abort();
}
}
原文链接:http://www.jxszl.com/biancheng/C/556721.html