Complete programmatic WCF service client wrapper in C#

Hi,the goal of this class was to avoid to use a app config file for the WCF object model so as to not have to restart my application (MDSManager) when updating endpoint url it is now done and you can update the endpoint on the fly!

 note: this post is based on Steve Wilkes’ article (see here)

 download the latest version of this class file (right click and ‘save as’ )


private void DisposeExistingServiceClientIfRequired() { if (this._serviceClient != null) { try { if (this._serviceClient.State == CommunicationState.Faulted) { this._serviceClient.Abort(); } else { this._serviceClient.Close(); } } catch { this._serviceClient.Abort(); } this._serviceClient = null; } } update october 29 : added 2 catch blocks so as to catch the REAL error message, please see this post:

and your app.config “serviceModel” section will be reduced to: (and could be reduced even more..)

update details (@Oct 16,2011):

programatic bindind in C#

update 2011/10/19: added a binding type switch
Bookmark the permalink.

About Xavier

7 years+ .net consulting

Leave a Reply

Your email address will not be published. Required fields are marked *

Captcha * Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.