System.ServiceModel.CommunicationObjectAbortedException

System.ServiceModel.CommunicationObjectAbortedException

System.ServiceModel.CommunicationObjectAbortedException is a WCF (Windows Communication Foundation) exception that indicates a communication object (like a client proxy, channel, or service host) was aborted, not cleanly closed.

In WCF, objects such as channels and clients follow a lifecycle (Created → Opened → Closing → Closed or Faulted). An abort is a hard, immediate termination—usually triggered when something goes wrong and WCF decides it cannot safely continue.

This exception is thrown when:

• You try to use or close an object that has already been aborted.
• WCF internally aborts the object due to a failure.

Common causes

1. Underlying communication failure

• Network interruption
• Server unavailable
• Timeout exceeded

2. Timeout issues

• Operation timeout
• Open/Close timeout exceeded

3. Unhandled exceptions in service

• If the service throws an exception and doesn’t handle it properly, the channel may fault → then abort.

4. Explicit Abort() call

If your code (or framework code) calls Abort() on:

• ClientBase
• ICommunicationObject
• ChannelFactory

5. Faulted state misuse

• Trying to Close() or reuse an object in Faulted state causes abort internally.

6. Serialization or protocol errors

• Message too large
• Invalid message format
• Security mismatch

When it is thrown?

You’ll typically see it during:

• client.Close()
• channel.Close()
• A service call after failure
• Reusing a faulted proxy

Example scenario

try
{
    client.CallService();
    client.Close();
}
catch
{
    client.Abort(); // Now object is aborted
}

If you later try

client.Close(); // CommunicationObjectAbortedException

How to prevent System.ServiceModel. CommunicationObjectAbortedException?

1. Follow proper Close/Abort pattern

try
{
    client.Close();
}
catch
{
    client.Abort();
}

Better (safe pattern):

try
{
    if (client.State == CommunicationState.Faulted)
        client.Abort();
    else
        client.Close();
}
catch
{
    client.Abort();
}

2. Don’t reuse faulted clients

Once faulted → dispose and recreate

if (client.State == CommunicationState.Faulted)
{
    client.Abort();
    client = new MyServiceClient();
}

3. Handle timeouts and retries

• Increase timeouts if needed
• Add retry logic (with new client instance)

4. Handle service exceptions properly

• Use FaultException instead of raw exceptions
• Prevent server-side crashes

5. Configure bindings correctly

• Increase maxReceivedMessageSize
• Adjust security/binding compatibility

What NOT to do?

• Don’t call Close() after Abort()
• Don’t reuse a faulted channel
• Don’t ignore communication exceptions
• Don’t assume using works safely with WCF clients (it can throw on dispose)

Best practices / use cases

When Abort() is appropriate:

• Fatal error occurred
• Timeout exceeded
• Object is faulted
• You need immediate cleanup

When Close() is appropriate:

• Normal, successful operation
• Graceful shutdown

More about System.ServiceModel. CommunicationObjectAbortedException

If you are experiencing A first chance exception of type 'System.ServiceModel. CommunicationObjectAbortedException' occurred in System.ServiceModel.dll,

Go to Control Panel -> Administrative Tools -> Component Services

In the UI tree on the left-side choose

Console Root -> Component Service -> Computers -> Distributed -> Local DTC -> right click Properties

Set the 'Allow Remote Clients', 'Allow Remote Administration', 'Allow Inbound', 'Allow Outbound' and 'No Authentication Required' options in the 'Local DTC Properties->Security' dialog on the client and server machines to avoid this problem.

Communication Object Aborted

Contents related to 'System.ServiceModel.CommunicationObjectAbortedException'

System.Net.Sockets.SocketException
System.Net.Sockets.SocketException