All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
在VS2005中调试Windows,Service_.net资料_编程技术

Writer: aaa Article type: Programming skills(编程技巧) Time: 2013/12/18 8:10:25 Browse times: 306 Comment times: 0

在VS2005中调试Windows,Service_.net资料_编程技术


Head photo

Go homepage
Upload pictures
Write articles

在VS2005中调试Windows Service_.net资料_编程技术-你的首页-uuhomepage.com

  1. MSDN推荐的方法

  1.1、调试windows服务的初始化、启动

  另写一个程序控制服务的初始化和启动

  注意:OnStart里写Log, OnStart里要在30秒返回. 不然启动就失败了! 所以OnStart里不要放太多代码! 可以用异步或线程.

  1.2、调试windows服务的其他方面

  1 ) 安装您的服务 : intallutils xx.exe

  2) 可从“服务控制管理器”、“服务器资源管理器”或代码启动服务

  3) vs: 设置相关断点,启动调试,再在工具栏中选择 调试->附加到进程..., 选择您的服务, 确定。

  2、trace方法

  2.1、添加调试方法

private static void DebugRun(string[] args)
{
 /*
 初始化服务
 OnStart();
 Console.ReadLine();
 OnStop();
 */
}

  2.2、改写程序入口为如下:

public static void Main(string[] args)
{
 #if DEBUG
  DebugRun(args);
 #else
  /*
  初始化服务
  */
 #endif
}

  2.3、加入2种调试代码

EventLog.WriteEntry("...");
System.Diagnostics.Debug.WriteLine("...");






There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.