static CMSClient cmsClient; //connection to CMS static void Main(string[] args) { //serverList = new List<WCFClientServer>(); try { Console.WriteLine("My Name: {0}", WindowsIdentity.GetCurrent().Name); cmsClient = ConnectToCMS(); if (cmsClient == null) { throw new Exception("Connection with CMS not established"); } Console.WriteLine("*Successfully connected to CMS*"); Prompt(); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { if (cmsClient != null) { cmsClient.Close(); } if (myChannel != null) { myChannel.Close(); } } Console.WriteLine("\n> Press enter to close program"); Console.ReadLine(); }