110,536
社区成员
发帖
与我相关
我的任务
分享
System.Runtime.Remoting.Channels.Tcp.TcpChannel ch;
System.Runtime.Remoting.Lifetime.ClientSponsor cp;
RMObject.RMObject rmobj;
private void btnLink_Click(object sender, EventArgs e)
{
System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider bsfs =
new System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider() { TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full };
System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider bcfs =
new System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider();
System.Collections.IDictionary props = new System.Collections.Hashtable();
props["port"] = 0;
ch = new System.Runtime.Remoting.Channels.Tcp.TcpChannel(props, bcfs, bsfs);
System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(ch,true);
//rmobj = new RMObject.RMObject();
string url = "tcp://192.168.1.101:9998";//tcp://127.0.0.1:9998 没问题
System.Runtime.Remoting.Activation.UrlAttribute urlattr = new System.Runtime.Remoting.Activation.UrlAttribute(url);
object[] args = null; //这里是构造函数传的参数
object[] attrs = { urlattr };
rmobj = (RMObject.RMObject)Activator.CreateInstance(typeof(RMObject.RMObject), args, attrs);
cp.Register(rmobj);
}
System.Runtime.Remoting.Channels.Tcp.TcpChannel ch;
private void btnStart_Click(object sender, EventArgs e)
{
System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider bsfs =
new System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider()
{ TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full };
System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider bcfs =
new System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider();
System.Collections.IDictionary props = new System.Collections.Hashtable();
props["port"] = 9998;
ch = new System.Runtime.Remoting.Channels.Tcp.TcpChannel(props, bcfs, bsfs);
System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(ch,true);
}