声明: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();
        

解决方案 »

  1.   

    如果你注册了通道
    Activator.CreateInstance(Type)
    只要一个参数就可以了
    得到的同样是远程的对象
    我昨天晚上刚测试过的
    你想得太复杂了
      

  2.   

    Activator.CreateInstance( "CRemoteObj", "nsCRemoteObj.CRemoteObj", attrs); 
      

  3.   

    http://www.cnblogs.com/lovecherry/archive/2005/05/24/161437.html
    这个很好,可以看看。
      

  4.   

    感谢您的回复。我看的途中在配置服务器的地方出现了些问题
    读取配置文件: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是我写的测试函数