积极答复者
Wcf host in Windows Service

问题
-
protected override void OnStart(string[] args) { ServiceHost host = new ServiceHost(typeof(WcfService.Service1)); host.Open(); } protected override void OnStop() { host.Close(); }
when I stop the service in the MMc,errors as follows
how to deal with it
- 已编辑 tdcqqcwh 2011年11月26日 2:34
- 已移动 ThankfulHeart 2011年11月27日 2:51 WCF & Webservice相关问题 (发件人:.NET Framework 一般性问题讨论区)
答案
-
Change your code as following:
0投票认定帖子内容有帮助
class WindowsHost
{
Private ServiceHost host=null;
protected override void OnStart(string[] args) { host = new ServiceHost(typeof(WcfService.Service1)); host.Open(); } protected override void OnStop() { host.Close(); }
}
Frank Xu Lei--谦卑若愚,好学若饥
【老徐的网站】:http://www.frankxulei.com/- 已标记为答案 Peter pi - MSFTModerator 2011年12月2日 8:17
全部回复
-
There is a temporary mismatch between the requested control and the state of the service to be controlled. The service may be in a state of start-pending, stop-pending, or stopped. Wait a few minutes, then retry your operation. Any long operation during the OnStop will cause this error unless you call this operation to another thread with a callback delegate.
Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework -
Change your code as following:
0投票认定帖子内容有帮助
class WindowsHost
{
Private ServiceHost host=null;
protected override void OnStart(string[] args) { host = new ServiceHost(typeof(WcfService.Service1)); host.Open(); } protected override void OnStop() { host.Close(); }
}
Frank Xu Lei--谦卑若愚,好学若饥
【老徐的网站】:http://www.frankxulei.com/- 已标记为答案 Peter pi - MSFTModerator 2011年12月2日 8:17