Fault-safe WCF Proxy Generator for Service Reference clients

WCF is great, but if a connection ever throws an exception for any reason it puts the client in the Faulted state and the client has to be aborted and recreated. It’s a pain in the ass since this can happen anywhere a client method is called.
In a previous post, I showed the dynamic generation of a proxy for a WCF channel.

Nowadays, I suspect most people create their clients using “Add Service Reference”. This generates a ClientBase client that suffers from the same problem as raw channels – if there’s ever an exception, you need to recreate the instance.

Following the earlier post, I created code to use the CIL Emit libraries to dynamically generate a fault-tolerant proxy around a given client. If an exception is thrown, the client is recreated with the correct authentication and whatever settings were used to construct it in the first place.
The code is up on github.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s