コード例 #1
0
        static void Main(string[] args)
        {
            var guid = new Guid("{75da63f2-9b76-4590-82b3-b8a108e53cf0}");

            using (var singleInstance = new SingleInstance(guid))
            {
                if (singleInstance.IsFirstInstance)
                {
                    if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\EasyImgur"))
                    {
                        Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\EasyImgur");
                    }

                    singleInstance.ListenForArgumentsFromSuccessiveInstances();

                    AppDomain.CurrentDomain.AssemblyResolve += FindDll;

                    foreach (string arg in args.Where(s => s != null))
                    {
                        if (arg == "/portable")
                        {
                            MakeSettingsPortable(Properties.Settings.Default);
                            _isInPortableMode = true;
                            Log.Info("Started in portable mode.");
                        }
                    }

                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    var form = new Form1(singleInstance, args);
                    Properties.Settings.Default.Reload(); // To make sure we can access the current settings.

#if DEBUG                                                 // We want VS to get the source of the exception instead of coming to this throw when debugging
                    Application.Run();                    // Don't put the new form instance here m'kay
#else
                    try
                    {
                        Application.Run();
                    }
                    catch (Exception ex)
                    {
                        Log.Error("Fatal exception in main thread: " + ex.ToString());
                        throw; // crash and burn; I'm not sure it's safe to show a message box so just crash
                    }
#endif
                }
                else
                {
                    singleInstance.PassArgumentsToFirstInstance(args);
                }
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: bexamous/EasyImgur
        static void Main(string[] args)
        {
            var guid = new Guid("{75da63f2-9b76-4590-82b3-b8a108e53cf0}");
            using (var singleInstance = new SingleInstance(guid))
            {
                if (singleInstance.IsFirstInstance)
                {
                    if(!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\EasyImgur"))
                        Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\EasyImgur");

                    singleInstance.ListenForArgumentsFromSuccessiveInstances();

                    AppDomain.CurrentDomain.AssemblyResolve += FindDll;

                    foreach (string arg in args.Where(s => s != null))
                    {
                        if (arg == "/portable")
                        {
                            MakeSettingsPortable(Properties.Settings.Default);
                            _isInPortableMode = true;
                            Log.Info("Started in portable mode.");
                        }
                    }

                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    var form = new Form1(singleInstance, args);
                    Properties.Settings.Default.Reload();   // To make sure we can access the current settings.

            #if DEBUG           // We want VS to get the source of the exception instead of coming to this throw when debugging
                    Application.Run(); // Don't put the new form instance here m'kay
            #else
                    try
                    {
                        Application.Run();
                    }
                    catch(Exception ex)
                    {
                        Log.Error("Fatal exception in main thread: " + ex.ToString());
                        throw; // crash and burn; I'm not sure it's safe to show a message box so just crash
                    }
            #endif
                }
                else
                    singleInstance.PassArgumentsToFirstInstance(args);
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Cologler/EasyImgur
 static void Main(string[] args)
 {
     var guid = new Guid("{75da63f2-9b76-4590-82b3-b8a108e53cf0}");
     using (var singleInstance = new SingleInstance(guid))
     {
         if (singleInstance.IsFirstInstance)
         {
             singleInstance.ListenForArgumentsFromSuccessiveInstances();
             Entry(singleInstance, args);
         }
         else
             singleInstance.PassArgumentsToFirstInstance(args);
     }
 }