Development environment when designing DTE
Keywords: DTE, design, Design Time, development environment
Friends who write Add-in programs I want to be familiar, like a famous unit test and reconstruction tool, etc., there is a macro, or more ... as long as it is embedded in the development environment of VS, I think DTE should start It is very important to feet.
Here I don't say so much, just how to get the physical path of the project when designing time, I want to do a component, I should not be unfamiliar with DESIGN TIME. You can get information on the web.config under the design, or take some information or data you defined.
Then DTE is in an envdte namespace called "Microsoft Development Environment 7.0". We only need to reference this component.
No words, there are too many, these MSDNs are available, the next simple example is the physical path to the project in the designer of the custom component, whether you pull the components from Toolbox to which project can be accurately Take the physical path to the project, which is the advantage of design.
Public class testControlDesigner: system.web.ui.design.controlDesigner
{
Public override string getdesigntimehtml ()
{
String html = "found nothing";
Try
{
Envdte.dte devenv = NULL;
Devenv = (envdte.dte) System.Runtime.InteropServices.Marshal.getActiveObject ("Visualstudio.DTE.7.1);
Array Projects = (System.Array) devenv.activeesolutionProjects;
IF ((Projects.Length == 0) || (Projects.length> 1))
{
HTML = "Exactly One Project Must Be Active";
}
Else
{
Envdte.Project Project = (envdte.project) (Projects.getValue (0));
System.io.fileinfo info = new system.io.fileinfo (Project.Fullname);
HTML = info.directory.ffullname;
}
}
Catch (Exception EX)
{
HTML = "Exception Occured:" EX.MESSAGE;
}
Return HTML;
}
}