声明:HelloServer功能:如果调用成功返回该字符服务端:TcpChannel chan1 = new TcpChannel(33937);
ChannelServices.RegisterChannel(chan1);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(HelloServer),"SayHello",WellKnownObjectMode.Singleton);客户端:TcpChannel chan1 = new TcpChannel();
ChannelServices.RegisterChannel(chan1);
object[] attrs = { new UrlAttribute("tcp://192.168.0.60:33937/SayHello") };
ObjectHandle handle = Activator.CreateInstance("ServerRemoteObject","ServerRemoteObject.ServerObject", attrs);
这个填什么参数? 还有这个?
HelloServer obj1 = (HelloServer)handle.Unwrap();
ChannelServices.RegisterChannel(chan1);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(HelloServer),"SayHello",WellKnownObjectMode.Singleton);客户端:TcpChannel chan1 = new TcpChannel();
ChannelServices.RegisterChannel(chan1);
object[] attrs = { new UrlAttribute("tcp://192.168.0.60:33937/SayHello") };
ObjectHandle handle = Activator.CreateInstance("ServerRemoteObject","ServerRemoteObject.ServerObject", attrs);
这个填什么参数? 还有这个?
HelloServer obj1 = (HelloServer)handle.Unwrap();
解决方案 »
- .net的面试题,怎么会出现JVM?
- 求提取网页内容的正则表达式
- datagridview 绑定强类型dataset,删除问题
- 关于C#中的DateTime的用法. timeinstring=(hour<10)?"0"+hour.ToString():hour.ToString();中的hour.Tostring():hour.tostring是什么意思
- 在dropdownlist中快速寻找内容
- 请教如何往另一台局域网的机器上拷贝文件,已知目标机器的权限
- 为什么看不到图片!?请各位帮帮忙!急,马上结贴!
- 如何用C#编写一个设置本地IP地址的程序!(在线等)
- 如何中快速取得大量IP相应的机器名?(在局域网中)
- 如何控制浮点数的有效数字个数?
- dataset如何更新数据中的数据
- 输出为3,2,1 怎样让输出为1,2,3
Activator.CreateInstance(Type)
只要一个参数就可以了
得到的同样是远程的对象
我昨天晚上刚测试过的
你想得太复杂了
这个很好,可以看看。
读取配置文件:RemotingConfiguration.Configure("RemoteServer.exe.config");
配置文件<system.runtime.remoting>
<application name="RemoteServer">
<service>
<wellknown type="test.Remoting.HelloServer,test.Remoting" objectUri="test.Remoting.HelloServer"
mode="Singleton" />
</service>
<channels>
<channel ref="tcp" port="33937"/>
</channels>
</application>
</system.runtime.remoting>
是不是我黑体字的地方填的有错还是其他原因,运行RemotingConfiguration.Configure("RemoteServer.exe.config");提示因发生异常“System.IO.FileNotFoundException: 系统找不到指定的文件。 (异常来自 HRESULT:0x80070002),HelloServer是我写的测试函数