宿主程序为windows服务的remoting

王朝c#·作者佚名  2006-12-17
宽屏版  字体: |||超大  

<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>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有