Pablo Galiano : Creating a VS2005 instance

Subscriptions

<November 2008>
SuMoTuWeThFrSa
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

News

Subscribe to Pablo Galiano by Email

Post Categories

Creating a VS2005 instance

Sometimes is very usefull for testing purposes to create a VS2005 instance, and them use that instance to have access to the DTE API stuff.

So, here is a code snippet to create a VS2005 instance and to open a solution:

            Type t = Type.GetTypeFromProgID("VisualStudio.DTE.8.0");

            DTE dte = (DTE)System.Activator.CreateInstance(t, true);

            try
            {
                dte.Solution.Open(@"C:\Temp\Temp.sln");

                //Wait some seconds to let VS open the solution
                System.Threading.Thread.Sleep(5000);
            }
            finally
            {
                dte.Solution.Close(false);
            }

Pablo

posted on Thursday, April 20, 2006 12:06 PM by pga