static int Main(string[] args)
        {
            int  retVal    = 0;
            bool need_save = false;

            try
            {
                parse_command_line(args);

                Console.WriteLine("Editing solution: {0}", solution_name);

                bool found_open_solution = GetDTEAndSolution();

                if (dte == null || solution == null)
                {
                    retVal = 1;
                }
                else
                {
                    MessageFilter.Register();

                    // Walk through all of the projects in the solution
                    // and list the type of each project.
                    foreach (DictionaryEntry p in projectDict)
                    {
                        string project_name = (string)p.Key;
                        string working_dir  = (string)p.Value;
                        if (SetProjectWorkingDir(solution, project_name, working_dir))
                        {
                            need_save = true;
                        }
                    }

                    if (config != null)
                    {
                        need_save = SetActiveConfig(config);
                    }

                    if (startup_project != null)
                    {
                        need_save = SetStartupProject(startup_project);
                    }

                    if (need_save)
                    {
                        if (found_open_solution == false)
                        {
                            ViaCOM.CallMethod(solution, "Close", null);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                retVal = 1;
            }
            finally
            {
                if (solution != null)
                {
                    Marshal.ReleaseComObject(solution);
                    solution = null;
                }

                if (dte != null)
                {
                    Marshal.ReleaseComObject(dte);
                    dte = null;
                }

                MessageFilter.Revoke();
            }
            return(retVal);
        }
示例#2
0
 //
 // Class containing the IOleMessageFilter
 // thread error-handling functions.
 // Start the filter.
 public static void Register()
 {
     IOleMessageFilter newFilter = new MessageFilter();
     IOleMessageFilter oldFilter = null;
     CoRegisterMessageFilter(newFilter, out oldFilter);
 }
示例#3
0
        //
        // Class containing the IOleMessageFilter
        // thread error-handling functions.

        // Start the filter.
        public static void Register()
        {
            IOleMessageFilter newFilter = new MessageFilter(); 
            IOleMessageFilter oldFilter = null; 
            CoRegisterMessageFilter(newFilter, out oldFilter);
        }