Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 853
Sam Avatar asked Feb 10 '11 23:02

Sam


1 Answers

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.

like image 56
Reed Copsey Avatar answered Nov 14 '22 21:11

Reed Copsey