_DTE.GetObject Method (String)
Visual Studio 2015
Gets an interface or object that is late-bound to the DTE object and can be accessed by name at run time.
Assembly: EnvDTE (in EnvDTE.dll)
Parameters
- Name
-
Type:
System.String
Required. The name of the object to retrieve.
GetObject is most useful in languages that do not support early binding. In this case, you can name the specific interface or object you want, for example, DTE.GetObject("VCProjects").
IExtenderSite.GetObject only supports the value "DTE" as the Name parameter. This is provided for Extender Providers to get to the DTE object.
public void GetObjectExample(DTE2 dte) { // NOTE: This example requires a reference to the // Microsoft.VisualStudio.VCCodeModel namespace. string[] idents = {"short", "class", "void", "var"}; VCLanguageManager langMan = (VCLanguageManager)dte.GetObject("VCLanguageManager"); // Validate the names in idents. string msg = ""; foreach (string name in idents) { if (langMan.ValidateIdentifier(name)) msg += "\"" + name + "\" is a valid identifier." + Environment.NewLine; else msg += "\"" + name + "\" is not a valid identifier." + Environment.NewLine; } MessageBox.Show(msg); }
Show: