Remoting 配置文件遇到的问题

虽然是个小问题,但是也花了我不少的时间。5555...

在工程中需要调用好几个宿主在windows Service 下的Remoting服务,我起初不知道怎样读取Remoting的配置文件,以至于在调用远程对象时,无法获得服务对象,而只获得的是本地对象。这就是没有读取Remoting配置文件的问题。

所以在Global.asax 文件里

    void Application_Start(object sender, EventArgs e)

    {

         RemotingConfiguration.Configure(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, false);

    }

这样所以得服务就可以用了。

附配置文件:

  
    
<? xml version="1.0" encoding="utf-8" ?>
< configuration >
< system.runtime.remoting >
< application >
< client url ="tcp://172.16.8.108:4500/FileServer" >
< activated type ="WebFiles.MailAttachServer,WebFiles" url ="tcp://172.16.8.108:4500/FileServer/MailAttachServer" />
< activated type ="WebFiles.CFileSvr,WebFiles" url ="tcp://172.16.8.172.16.8.108:4500/FileServer/CFileSvr" />
< activated type ="WebFiles.CFileIndexSvr,WebFiles" url ="tcp://172.16.8.108:4500/FileServer/CFileIndexSvr" />
< activated type ="WebFiles.ArchiveFileIndexSvr,WebFiles" url ="tcp://172.16.8.108:4500/FileServer/ArchiveFileIndexSvr" />
< activated type ="WebFiles.ArchiveFileSvr,WebFiles" url ="tcp://172.16.8.108:4500/FileServer/ArchiveFileSvr" />
< activated type ="WebFiles.TiffSvr,WebFiles" url ="tcp://172.16.8.108:4500/FileServer/TiffSvr" />
</ client >
< channels >
< channel ref ="tcp" />
</ channels >
< client url ="tcp://172.16.8.108:4501" name ="MailRemoting" >
< activated type ="WebMail.CAsyncMailSvr,WebMail" url ="tcp://172.16.8.108:4501" />
</ client >
< client url ="tcp://172.16.8.108:4503/ExportServer" name ="ExportRemoting" >
< activated type ="WebExport.CWebExport,WebExport" url ="tcp://172.16.8.108:4503/ExportServer/CWebExport" />
</ client >
< client url ="tcp://172.16.8.108:4650/IPCService" name ="RuntimeServer" >
< wellknown type ="WFRuntimeServer.IWFRuntimeSrv,IWFRuntimeSrv" url ="tcp://172.16.8.108:4650/IPCService/CRuntimeSrv" />
</ client >
</ application >
</ system.runtime.remoting >
</ configuration >

你可能感兴趣的:(配置文件)