static void Main(string[] args) { // Camera Remote Access Service. var camClient = new CamRAC.CamRemoteAccessContractClient(); // APAS Remote Access Service. var client = new SystemServiceClient(); try { client.Open(); client.__SSC_Connect(); // perform the user process. UserProc(client, camClient); client.__SSC_Disonnect(); } catch (AggregateException ae) { Console.ForegroundColor = ConsoleColor.Yellow; Console.BackgroundColor = ConsoleColor.Red; var ex = ae.Flatten(); ex.InnerExceptions.ToList().ForEach(e => { Console.WriteLine($"Error occurred, {e.Message}"); }); Console.ResetColor(); } finally { client.Close(); } //Console.WriteLine("Press any key to exit."); //Console.ReadKey(); }