惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Darknet – Hacking Tools, Hacker News & Cyber Security
V
Vulnerabilities – Threatpost
Cloudbric
Cloudbric
G
GRAHAM CLULEY
S
Securelist
Schneier on Security
Schneier on Security
Help Net Security
Help Net Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Project Zero
Project Zero
Spread Privacy
Spread Privacy
P
Privacy International News Feed
C
Cyber Attacks, Cyber Crime and Cyber Security
Cisco Talos Blog
Cisco Talos Blog
T
Tailwind CSS Blog
博客园_首页
有赞技术团队
有赞技术团队
Simon Willison's Weblog
Simon Willison's Weblog
Stack Overflow Blog
Stack Overflow Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Latest news
Latest news
T
Tor Project blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Attack and Defense Labs
Attack and Defense Labs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
O
OpenAI News
J
Java Code Geeks
T
Tenable Blog
K
Kaspersky official blog
AWS News Blog
AWS News Blog
S
Security @ Cisco Blogs
The GitHub Blog
The GitHub Blog
T
Threatpost
月光博客
月光博客
H
Heimdal Security Blog
Security Latest
Security Latest
The Hacker News
The Hacker News
Y
Y Combinator Blog
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
C
Cisco Blogs
美团技术团队
Microsoft Security Blog
Microsoft Security Blog
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
C
CERT Recently Published Vulnerability Notes
D
Docker
Google Online Security Blog
Google Online Security Blog
D
DataBreaches.Net
V
Visual Studio Blog
H
Help Net Security

博客园 - neverlost

客户端开发杂记 html5 元素 来自 nativeformelements.com 闲扯,面向对象的ext4中的一些事儿1 Ext 4 beta1 发布似乎仍不给力 .net 下比较蛋疼的word 表格转excel表格 浅述教学上基于Media Player的视频切片方式 webservice传输数据量较大的情况的解决方案 - neverlost - 博客园 现场保障系统开发过程中增加并行处理(一) vs2010中文版+codesmith 5.2 安装失败 转的 winform开发连接webservice中单向证书 .net 写的 webservice 给java调用 ext中使用tab方式 ext做列表页面关于查询多行的办法 关于架构的问题 ext的grid 获取页面内容方式 - neverlost - 博客园 微软.net下 charting 要注意的事情 - neverlost .net 获取 其他类型的webservice的方式以及看法 2条路 代码生成 or 配置 2.1 2条路 代码生成 or 配置 2
.net下开发windows服务的经验
neverlost · 2010-04-08 · via 博客园 - neverlost

首先由于windows服务不能够在vs2008里直接进行调试所以 所以在开发的时候可以用另一个办法来调试:
在program.cs文件里main方法做如下修改:
            #if (!DEBUG)
               System.ServiceProcess.ServiceBase[] ServicesToRun;
               ServicesToRun = new System.ServiceProcess.ServiceBase[]
               {
                   new 你的服务类初始化();//就是默认创建的那个部分
               };
               System.ServiceProcess.ServiceBase.Run(ServicesToRun);
            #else
               // 你要调试的方法入口
                 System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
            #endif

当项目处于debug时,则可以进行调试.

其次 一般写这服务很多都需要定时机制,而普通的windows的form类的timer控件在服务里是不能使用的
所以只有使用下面的代码:
          System.Timers.Timer t = new System.Timers.Timer(doubleTimeInterval); //定时
            t.AutoReset = true; //自动重置
            t.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); //加载方法
            t.Start();

当开发调试工作已经完成就需要在系统里安装服务了.
点击工程名右键添加安装程序类,创建,然后在设计窗体里看到这个安装程序类有2个组件,一个是设置服务名称的,另一个设置自动启动还有服务使用的账号这些东西.
都搞好了 然后生成文件.

在vs2008菜单的Visual Studio Tools里有个Visual Studio 2008 命令提示工具 vista下以管理员方式运行,然后 键入命令
installutil 生成的文件地址\生成的exe文件 然后可以去服务里启动 好了 服务运行了吧.
当然 如果要卸栽 就在刚才的命令里加上 \u

如果要知道服务在运行的时候究竟情况怎么样,或者想知道时间点是否进入了,那么可以在代码增加记录日志类:
            EventLog  eventLog1 = new EventLog();
            eventLog1.Source = "service";
            eventLog1.WriteEntry("Service start");
另外注意下 如果需要读取配置文件 则应该是 后缀为exe.config的这个