void LoadScriptEngine()
        {
            try
            {
                if (_monitor == null)
                {
                    var scriptDirectory = Path.Combine(_workingDirectory, "Scripts");
                    var scriptFileName  = Path.Combine(scriptDirectory, "SSMSAddin.py");
                    _monitor = new ScriptMonitor(scriptFileName);

                    _monitor.OnScriptLoading   += new ScriptMonitorEvent(_monitor_OnScriptLoading);
                    _monitor.OnScriptLoaded    += new ScriptMonitorEvent(_monitor_OnScriptLoaded);
                    _monitor.OnScriptUnLoading += new ScriptMonitorEvent(_monitor_OnScriptUnLoading);
                    _monitor.OnEngineMessage   += new MessageEvent(_monitor_OnEngineMessage);
                    _monitor.Activate();
                }
            }
            catch (Exception x)
            {
                LogError("Error LoadScriptEngine: " + x.Message);
            }
        }
        public static void Main(string[] args)
        {
            if (args.Length == 0 || (args.Length == 1 && (args[0] == "?" || args[0] == "/?" || args[0] == "-?" || args[0].ToLower() == "help")))
            {
                Console.WriteLine(usage);
            }
            else
            {
                if (args[0].Trim().ToLower() == "/prj")
                {
                    scriptFile = ResolveScriptFile(args[1]);

                    try
                    {
                        VS71IDE ide = new VS71IDE();
                        ide.IsolateProject(scriptFile, Path.Combine(Path.GetDirectoryName(scriptFile), Path.GetFileNameWithoutExtension(scriptFile)));
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("Specified file could not be linked to the temp project:\n" + e.Message);
                    }
                }
                else
                {
                    scriptFile =  ResolveScriptFile(args[0]);

                    try
                    {
                        VS71IDE ide = new VS71IDE();
                        ide.ComposeProject(scriptFile);

                        ScriptMonitor monitor = new ScriptMonitor(scriptFile);

                        Environment.CurrentDirectory = Path.GetDirectoryName(scriptFile);

                        //open project

                        Process myProcess = new Process();
                        myProcess.StartInfo.FileName = VS71IDE.IDEFile;
                        myProcess.StartInfo.Arguments = VS71IDE.GenerateCmdArgs(scriptFile);
                        myProcess.Start();
                        myProcess.WaitForExit();

                        //do clean up
                        foreach (string file in VS71IDE.filesToClean.Keys) //clean imported files
                        {
                            if (File.Exists(file))
                            {
                                File.SetAttributes(file, FileAttributes.Normal);
                                File.Delete(file);
                            }
                        }
                        if (File.Exists(Path.ChangeExtension(scriptFile, ".resx"))) //clean auto-generated files
                            File.Delete(Path.ChangeExtension(scriptFile, ".resx"));
                        Directory.Delete(VS71IDE.projectDir, true);  //clean whole project directory
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("Specified file could not be linked to the temp project:\n" + e.Message);
                    }
                }
            }
        }
        static public void Main(string[] args)
        {
            if (args.Length == 0 || (args.Length == 1 && (args[0] == "?" || args[0] == "/?" || args[0] == "-?" || args[0].ToLower() == "help")))
            {
                Console.WriteLine(usage);
            }
            else
            {
                if (args[0].Trim().ToLower() == "/prj")
                {
                    scriptFile = ResolveScriptFile(args[1]);

                    try
                    {
                        VS71IDE ide = new VS71IDE();
                        ide.IsolateProject(scriptFile, Path.Combine(Path.GetDirectoryName(scriptFile), Path.GetFileNameWithoutExtension(scriptFile)));
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("Specified file could not be linked to the temp project:\n" + e.Message);
                    }
                }
                else
                {
                    scriptFile = ResolveScriptFile(args[0]);

                    try
                    {
                        VS71IDE ide = new VS71IDE();
                        ide.ComposeProject(scriptFile);

                        ScriptMonitor monitor = new ScriptMonitor(scriptFile);

                        Environment.CurrentDirectory = Path.GetDirectoryName(scriptFile);

                        //open project

                        Process myProcess = new Process();
                        myProcess.StartInfo.FileName  = VS71IDE.IDEFile;
                        myProcess.StartInfo.Arguments = VS71IDE.GenerateCmdArgs(scriptFile);
                        myProcess.Start();
                        myProcess.WaitForExit();

                        //do clean up
                        foreach (string file in VS71IDE.filesToClean.Keys)                         //clean imported files
                        {
                            if (File.Exists(file))
                            {
                                File.SetAttributes(file, FileAttributes.Normal);
                                File.Delete(file);
                            }
                        }
                        if (File.Exists(Path.ChangeExtension(scriptFile, ".resx")))                         //clean auto-generated files
                        {
                            File.Delete(Path.ChangeExtension(scriptFile, ".resx"));
                        }
                        Directory.Delete(VS71IDE.projectDir, true);                          //clean whole project directory
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("Specified file could not be linked to the temp project:\n" + e.Message);
                    }
                }
            }
        }