Reputation: 20050
Our application is composed of 2 application domains. Some method calls (logging) in the secondary appdomain must be "redirected" to the first appdomain.
This is done by setting up a WCF service on the main appdomain, and having the secondary appdomain call its operations.
For example, here's code that runs in the 2nd AppDomain:
Logger.Debug("Message");
Will internally be redirected as a WCF service call to the first AppDomain:
public void Debug(string message)
{
if (useService)
{
logProxy.Log(message);
}
}
The problem is that on random occasions, i'm seeing the service proxy transition into the Faulted state.
Digging deeper, I've found out that when the thread that makes the service calls gets shut down, on some occasions the proxy object will become faulted.
My question is -- how can i protect myself from the scenario where a WCF service call is performed, but the thread that started the call gets shutdown? (possibly before receiving a reply).
Also -- is ClientBase favorable over using the ChannelFactory option for creating a client proxy?
Some extra details on my setup:
Upvotes: 1
Views: 586
Reputation: 8645
Only the client can handle this.
ServiceClient client = new ServiceClient();
try {
client.Operation();
}
catch(Exception ex)
{
if (client.State == CommunicationState.Faulted)
{
client.Abort();
client = new ServiceClient();
}
}
Upvotes: 1