代码乱了(靳如坦的技术blog)

专注于.net,c#,Ajax、Sql Server、SmartClient等相关的开发
posts - 90, comments - 412, trackbacks - 6, articles - 2
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理

调试windows services

Posted on 2008-06-30 01:07 代码乱了 阅读(140) 评论(0)  编辑 收藏 网摘 所属分类: .net新技术

When I need to debug a windows service I usually make a call to Thread.Sleep and then attach the debugger manually.

   1:  protected override void OnStart(string[] args)
   2:  {
   3:   
   4:      Thread.Sleep(10000);
   5:   

 

But now I have realized that there is an easier solution to this problem and it is to launch the debugger by yourself!

   1:          protected override void OnStart(string[] args)
   2:          {
   3:   
   4:              #if DEBUG
   5:              if (Properties.Settings.Default.Debug)
   6:              {
   7:                  System.Diagnostics.Debugger.Launch();
   8:              }
   9:              #endif

标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
"五向定位"职业成长路线公开课(上海、南京、大连)
Google站内搜索


相关链接: