DTEClass Class
Assembly: EnvDTE (in envdte.dll)
Programatically creating new instances of Visual Studio is possible. In Visual Studio .NET 2002 the line of code
DTE dteObject = new DTE();
could be used to instantiate a new version of VS 2002. For side by side reasons, this functionality was removed, and now you need to use a different method to create a new instance. This code looks like:
System.Type t = System.Type.GetTypeFromProgID("VisualStudio.DTE.8.0");
object obj = System.Activator.CreateInstance(t, true);
EnvDTE.DTE dteObject = (EnvDTE.DTE)obj;
If you use the code to new an instance of DTE, then one of two outcomes will result. Either you will instantiate an instance of Visual Studio .NET 2002 (if it is installed on that computer), or an exception will be thrown (if VS 2002 is not installed on that computer). Using the System.Type.GetTypeFromProgID method is always better because it is guaranteed to work, it allows you to specify a specific version of Visual Studio to run (like above, where the specific version is given) or you can specify a version independant ProgID, such as VisualStudio.DTE, and create any version of Visual Studio that may be installed.
- 6/7/2006
- Craig Skibo - MSFT