Remoting中的配置

配置Remoting共有如下二个方面 ,一个是服务端配置,一个是客户端配置
服务端配置如何(宿主为IIS)
<system.runtime.remoting>
  <application>
   <service>
    <wellknown mode="Singleton" type="ComPlusLibrary.Test,ComPlusLibrary" objectUri="ServerSide.rem" >
    </wellknown>
        <wellknown mode="Singleton" type="JobServerLib.JobServerImpl,JobServerLib" objectUri="JobServer.rem" />
        <channels>
          <channel ref="http" useDefaultCredentials="true" />
        </channels>
      </service>
  </application>
 </system.runtime.remoting>

在配置完服务器之后,我们可以通过这样的方式,看看我们有没有配置正确
 
http://itc006/TestRemoting/ServerSide.rem?wsdl如果出来一个XML文档,那就说明配置对了。

注意:在wellknown中的Type是类全名,Assembly的名(不需要DLL)
二是客户端配置
 <system.runtime.remoting>
    <application>
      <client>
        <wellknown url="http://itc006/TestRemoting/ServerSide.rem" type="ComPlusLibrary.Test,ComPlusLibrary">
        </wellknown>
        </client>
    </application>
   
  </system.runtime.remoting>
 
最后在客户端使用:
            System.Runtime.Remoting.RemotingConfiguration.Configure("client.exe.config");
先注册一下。

Test test = new ComPlusLibrary.Test();
            ICustomer cusomer = test.GetCustomer();
            cusomer.Name = "testing..";
            MessageBox.Show(cusomer.Name);
 
基本上就是这样,现在还有两个问题需要解决:
一个是自定义REMOTING的头信息,二是通过二进制的形式传递数据。
 
 
 
原文地址:https://www.cnblogs.com/DaiWei/p/344501.html