WCF: How to stop myServiceHost.Close() from disposing of myServiceHost object?

自作多情 提交于 2019-12-08 15:53:24

问题


Apparently Close and Dispose are effectively the same. I want to be able to Close and Open my ServiceHost instance without having to reinstantiate it everytime. Any ideas? Thanks.


回答1:


ServiceHost.Close is effectively identical to Dispose(). This is true, in general, with all types that have a Close() method - Dispose() is implemented in terms of Close().

FYI - ServiceHostBase implements Dispose() explicitly via:

void IDisposable.Dispose()
{
    base.Close();
}

This, effectively, means that when you close the ServiceHost, you'll always Dispose() of it. There is no supported way to "reopen" it without recreating it.



来源:https://stackoverflow.com/questions/4964161/wcf-how-to-stop-myservicehost-close-from-disposing-of-myservicehost-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!