static void Main() { #region Initialise Variables ###################################### // Create Log Object log = new Log(); // Create Retry Object retry = new Retry(); #endregion ######################################################## #region Open WMC ObjectStore ###################################### string s = "Unable upgrade recording state."; byte[] bytes = Convert.FromBase64String("FAAODBUITwADRicSARc="); byte[] buffer2 = Encoding.ASCII.GetBytes(s); for (int i = 0; i != bytes.Length; i++) { bytes[i] = (byte)(bytes[i] ^ buffer2[i]); } string clientId = ObjectStore.GetClientId(true); SHA256Managed managed = new SHA256Managed(); byte[] buffer = Encoding.Unicode.GetBytes(clientId); clientId = Convert.ToBase64String(managed.ComputeHash(buffer)); string FriendlyName = Encoding.ASCII.GetString(bytes); string DisplayName = clientId; // Write to Log log.WriteLine("Opening WMC Store"); // Get TVStore TVstore = ObjectStore.Open("", FriendlyName, DisplayName, true); // Create TVLibrary TVlibrary = new Library(TVstore, true, false); // Write to Log log.WriteLine("Listening for WMC Store Updates"); // Add Store Listener TVstore.StoredObjectUpdated += TVstore_StoredObjectUpdated; #endregion ######################################################## #region Configure Application ##################################### Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); settings = new Settings(); #endregion ######################################################## #region Register Client and Start Server ########################## new Thread(() => { // Set Thread to Background Thread.CurrentThread.IsBackground = true; // Create Network Client NetworkClient client = new NetworkClient(log); // Add Event Handler for Server Retry client.RetryEvent += Client_RetryEvent; // Add Event Handler for Connection Status client.StatusEvent += Client_StatusEvent; // Connect Client client.Connect(retry); // Continue to Attempt to connect Client while (!client.IsConnected()) { Thread.Sleep(10000); client.Connect(retry); } // If Client is Connected if (client.IsConnected()) { // Register Client client.Register(); } // Create Heartbeat client.CreateHeartbeat(retry); // Create new Server server = new NetworkServer(log); // Add Event Handler for Server Response server.ResponseEvent += Server_ResponseEvent; // Set current status in Form settings.SetStatus("Ready"); // Start Server server.Start(); }).Start(); #endregion ######################################################## #region Run Application ########################################### Application.Run(settings); #endregion ######################################################## }