您可以在这里快速查找:


 
您的位置: 编程学习 > asp.net教程 > 200511
文章分类

Java技术
2005: 03 04 05 06 07 08
09 10 11 12
2006: 01 02

Asp.net
2005: 07 08 09 10 11 12
2006: 01 02

VB编程
2006: 02

Asp编程
2005: 11 12
2006: 01 02

C++/VC
2005: 10 11 12
2006: 01 02

Delphi
2005: 12
2006: 01 02

其它

 本文章适合所有读者

宿主程序为windows服务的remoting

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