本文介绍了如何使Windows服务的启动"自动(延时启动)QUOT;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情景:

运行作为Windows服务的WCF服务。账户是用户

A WCF service running as a Windows Service. Account is "User".

什么是做的:

我已经覆盖了OnBeforeInstall在projectinstaller才能够设置为从一个配置文件中的用户名和密码。

I have overridden the OnBeforeInstall in the projectinstaller to be able to set username and password from a config file.

我能够做什么:

我希望能够将startType为自​​动(延迟开始)

I'd like to be able to set the starttype as Automatic (Delayed Start)

我曾尝试:

我把在重写OnBeforeInstall

I put the following coderow in the overridden OnBeforeInstall

serviceInstaller1.StartType = ServiceStartMode.Automatic + 1;

想我会欺骗ServiceStartMode枚举为代表自动(延迟启动),没有工作。没有尝试过任何东西,只是因为我找不到任何尝试。

Figured I would trick the ServiceStartMode enum into representing Automatic (Delayed Start), didn't work. Haven't tried anything more simply because I couldn't find anything to try.

我已经找到在网络上:

我发现,自动(延时启动)将在.NET 4中可用,但它不能帮助我的现在。

口发现,DelayedAutoStart可以被添加到该服务的配置重点,但这种感觉就像一个黑客如果我应该这样做的代码。但也许这是在这一点上可对我来说唯一的解决办法?

I found out that Automatic (Delayed Start) will be available in .NET 4, but that doesn't help me right now.MSDNI found out that DelayedAutoStart could be added to the service's configuration key, but this feels like a hack if I should do this from code. But maybe this is the only solution available for me at this point?



  • WS2008: Startup Processes and Delayed Automatic Start

任何想法?

罗伯特·佩尔松,瑞典

推荐答案

现在的.NET 4.0是在这里:

Now that .NET 4.0 is here:

serviceInstaller1.StartType = ServiceStartMode.Automatic;
serviceInstaller1.DelayedAutoStart = true;

这篇关于如何使Windows服务的启动"自动(延时启动)QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 03:07
查看更多