Reputation: 2669
So i have a WCF services that is hosted in a VB6 app via COM. The problem i have is when you debug the VB6 app the application is launched under the VB6.exe process not a separate process like Visual Studio. If i terminate the app by hitting stop in the debugger or there is an exception then the next time i run the app it tries to start the wcf host again an i get this error
The ChannelDispatcher at 'http://localhost:8080/basic' with contract(s) '"IEvalService"' is unable to open its IChannelListener.
I know this is because the ServiceHost.Abort or ServiceHost.Close is not being called in these situations. I call this when i close the app normally and it works the next time. The only way i can fix it is to restart VB.
Is there a way i can check to see if the service host is running, abort it and then start it again?
Upvotes: 0
Views: 274
Reputation: 1870
As far as the app crashing due to an exception: you might want to consider wrapping the main method in a try-catch and close the service if there is an exception.
As far as the ChannelDispatcher error, one way to handle it would be to put the code in a try-catch and catch specifically for this exception; in the catch block, start the service under a different port.
Upvotes: 0