I have a method which accesses a service to perform two calls. Here is the (simplified) client code:
try
{
using (var client = new IntegrationServiceClient())
{
int taskID = client.CreateTask(param, taskType, taskDate);
if (taskID < 0)
{
//There was some error
return -1;
}
if (!client.ExecuteTask(taskID, taskType))
{
//There was some error
}
}
}
catch (Exception ex)
{
LogManager.Log("Error while creating and executing task", ex);
}
I’m getting a CommunicationObjectFaultedException exception only on the second call. How is this possible? If there was some kind of fault, shouldn’t I get a FaultException (or some other exception) after the first call? Is there something other than an exception that can cause the proxy to enter a faulted state?
It seems there was a bad
web.configfile. The stack trace was telling me there was an error on line with the second call because that was the last meaningful line within theusingstatement, after which the proxy is disposed. TheCommunicationObjectFaultedExceptionis raised only when disposing the proxy.It was just the way that the code was written that caused the stack trace look like the exception was thrown when calling the second method.