.NET开发

本类阅读TOP10

·NHibernate快速指南(翻译)
·vs.net 2005中文版下载地址收藏
·【小技巧】一个判断session是否过期的小技巧
·VB/ASP 调用 SQL Server 的存储过程
·?dos下编译.net程序找不到csc.exe文件
·通过Web Services上传和下载文件
·学习笔记(补)《.NET框架程序设计(修订版)》--目录
·VB.NET实现DirectDraw9 (2) 动画
·VB.NET实现DirectDraw9 (1) 托管的DDraw
·建站框架规范书之——文件命名

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
宿主程序为windows服务的remoting

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

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


相关文章

相关软件