一箭工作室

大家一起来学软件开发

博客园 首页 新随笔 联系 订阅 管理
        .NET Remoting除了提供通过代码创建和配置信道和远程对象之外,还提供通过Configuration File即配置文件,调用RemotingConfiguration.Configure方法来完成.NET Remoting——first things first阶段所有的工作。同时,还可以在运行时,更改IP地址、协议、端口及远程对象。因此,若应用场景不是特别复杂,强调建议通过配置文件完成所有.NET Remoting配置工作。

服务器端配置文件事件如下:

<configuration>

 <system.runtime.remoting>

    <application>

      <service>

        <wellknown mode="Singleton"

type="Inovout.Remoting.RemotingObject.Calcuator,RemotingObjectClassLibrary"

                   objectUri="Calculator.rem"/>

      </service>

      <channels>

        <channel ref="tcp" port="8891"/>

      </channels>

    </application>

 </system.runtime.remoting>

</configuration>

客户端配置文件事例如下:

<configuration>

 <system.runtime.remoting>

    <system.runtime.remoting>

      <application>

        <client>

          <wellknown

type="Inovout.Remoting.RemotingObject.Calcuator,RemotingObjectClassLibrary"

             url="tcp://localhost:8891/Calculator.rem"

            />

        </client>

        <channels>

          <channel

             ref="tcp"/>

        </channels>

      </application>

    </system.runtime.remoting>

 </system.runtime.remoting>

</configuration>

注册方法事例代码如下:

// ClientWindowsApplication.exe.config为客户端或服务器端配置文件名。

RemotingConfiguration.Configure("ClientWindowsApplication.exe.config", true);

posted on 2006-11-25 10:39  一箭  阅读(291)  评论(0)    收藏  举报