Building WCF client applications using a client proxy with an application configuration file


Before starting

Create or edit an application configuration file for the client, as described in: Create a WCF custom channel administratively by supplying binding and endpoint information in an application configuration file


Instantiate and open an instance of the client proxy. The parameter passed to the generated proxy must be the same as the endpoint name specified in the client configuration file, for example Endpoint_WMQ:

MyClientProxy myClient = new MyClientProxy("Endpoint_WMQ");
            try {
                   myClient.myMethod("HelloWorld!");
                   myClient.Close();
            }
            catch (TimeoutException e) {
                Console.Out.WriteLine(e);
                myClient.Abort();
            }
            catch (CommunicationException e) {
                Console.Out.WriteLine(e);
                myClient.Abort();
            }
            catch (Exception e) {
                Console.Out.WriteLine(e);
                myClient.Abort();
            }
Parent topic: Building client applications for WCF