| 楼主:李府隆 | | |
等级:进士 经验∶3663 网站内容[大区版主]
| |
| 宿主程序为windows服务的remoting |
|
|
<xmp> remoting一般宿主在windows服务里. 新建一个windows服务,在OnStart方法里写入如下代码: protected override void OnStart(string[] args) { // TODO: 在此处添加代码以启动服务。 EventLog myLog=new EventLog(); myLog.Source="MonthListService"; bool failed=false; try { RemotingConfiguration.Configure(@"MonthService.exe.config"); myLog.WriteEntry("从配置文件MontService.exe.config配置成功!"); } catch(Exception ex) { myLog.WriteEntry("配置失败"+ex.Message,EventLogEntryType.Error); failed=true; } if(failed==true) { //MessageBox. } } 配置文件MonthService.exe.config的内容如下,因为Machine.config里有已经配置好的channel等,所以用channel ref="tcp server" port="8085"来引用Machine.config里的设置. <configuration> <system.runtime.remoting> <application name="VersionHost"> <channels> <channel ref="tcp server" port="8085"/> </channels> <service> <wellknown displayName="MyService" type="VersionDemo.VersionServer,VersionServer,Version=2.0.0.0" mode="SingleCall" objectUri="Version"/> </service> </application> <debug loadType="true"/> </system.runtime.remoting> </configuration>
使用installunit exeFilePath来注册到windows服务即可. </xmp> | 做人要厚道,转载请注明来自飞卢(faloo.com) |
|