我爱Aspx >> Asp.Net >> Microsoft .Net Remoting系列专题之一:.Net Remoting基础篇TcpChannel channel = new TcpChannel(8080);
ChannelServices.ReGISterChannel(channel);
在实例化通道对象时,将端口号作为参数传递。然后再调用静态方法ReGISterChannel()来注册该通道对象即可。
2、注册远程对象注册了通道后,要能激活远程对象,必须在通道中注册该对象。根据激活模式的不同,注册对象的方法也不同。
(1) SingleTon模式对于WellKnown对象,可以通过静态方法RemotingConfiguration.RegisterWellKnownServiceType()来实现:RemotingConfiguration.RegisterWellKnownServiceType(
typeof(ServerRemoteObject.ServerObject),
"ServiceMessage",WellKnownObjectMode.SingleTon);
(2)SingleCall模式注册对象的方法基本上和SingleTon模式相同,只需要将枚举参数WellKnownObjectMode改为SingleCall就可以了。RemotingConfiguration.RegisterWellKnownServiceType(
typeof(ServerRemoteObject.ServerObject),
"ServiceMessage",WellKnownObjectMode.SingleCall);
(3)客户端激活模式对于客户端激活模式,使用的方法又有不同,但区别不大,看了代码就一目了然。
RemotingConfiguration.ApplicationName = "ServiceMessage";
RemotingConfiguration.RegisterActivatedServiceType(
typeof(ServerRemoteObject.ServerObject));
为什么要在注册对象方法前设置ApplicationName属性呢?其实这个属性就是该对象的URI。对于WellKnown模式,URI是放在RegisterWellKnownServiceType()方法的参数中,当然也可以拿出来专门对ApplicationName属性赋值。而RegisterActivatedServiceType()方法的重载中,没有ApplicationName的参数,所以必须分开。
3、注销通道如果要关闭Remoting的服务,则需要注销通道,也可以关闭对通道的监听。在Remoting中当我们注册通道的时候,就自动开启了通道的监听。而如果关闭了对通道的监听,则该通道就无法接受客户端的请求,但通道仍然存在,如果你想再一次注册该通道,会抛出异常。
//获得当前已注册的通道;
IChannel[] channels = ChannelServices.RegisteredChannels;
Ҷƪл˵?
Microsoft .NET Remoting:技术概..[05-15]
Microsoft .Net Remoting系列专题..[05-15]
.NET Framework中的串行化操作[05-15]
.Net Remoting与Server 对象详解[05-15]
解析.Net框架下的序列化机制[05-15]
微软 .NET Remoting体系结构评估[05-15]
ASP.NET创建Web服务之使用事务[05-15]
ASP.NET创建Web服务之发布和部署[05-15]
HTTP 安全性和 ASP.NET Web 服务[05-15]
运用VB.net创建Web服务访问程序[05-15]
一步一步学Remoting之四:承载方..[05-15]
一步一步学Remoting之一:从简单..[05-15]
一步一步学Remoting之五:异步操..[05-15]
Microsoft .NET Remoting:技术概..[05-15]
Remoting事件机制续[05-15]
Remoting和Web服务的区别[05-15]
Microsoft .Net Remoting系列专题..[05-15]
如何解决Remoting无法传输存储过..[05-15]
.NET Framework中的串行化操作[05-15]
.Net Remoting与Server 对象详解[05-15]