上一次我们使用编码的方式配置Remoting连接,今天我们将说利用配置文件配置Remoting连接,至于用配置文件的好处我就不多说了,现在我们来看:服务器端配置文件: <?xml version="1.0" encoding="utf-8" ?><configuration> <system.runtime.remoting> <application> <service> <wellknown mode="Singleton" type="General.HelloServer, General" objectUri="SayHello" /> </service> <channels> <channel port="8090" ref="http"/> </channels> </application> </system.runtime.remoting></configuration> 以上的配置节点表示的意思我就不用多说了,跟编码配置文件意义一样。那么我们怎么加载这个配置文件呢?有两种方法:第一种:直接指定备件文件路径 RemotingConfiguration.Configure(@"C:\Documents and Settings\gj1\My Documents\Visual Studio 2005\Projects\ConsoleApplication1\ConsoleApplication1\App.config"); 第二种: RemotingConfiguration.Configure( AppDomain.CurrentDomain.SetupInformation.ConfigurationFile ); 客户端的配置文件:在Web.Config里加入: <system.runtime.remoting> <application> <client> <wellknown type="HelloServer, General" url="http://localhost:8090/SayHello" /> </client> <channels> <channel ref="http" port="0"></channel> </channels> </application> </system.runtime.remoting> 加载客户端的配置文件跟服务器端一样。DEMO实现功能跟昨天一样,只是注册方式变成了利用配置文件完整代码下载 相关文章: