Hi,
for a Visual Studion 2005 Add In i need to access the currently selected
project. I have don this by the following code line:
DTE2 dte2 = (DTE2) Marshal.GetActiveObject("VisualStudio.DTE.8.0");
Project project = dte2.ActiveDocument.ProjectItem.ContainingProject;
My problem is that some times DTE2#ActiveDocument is null. I don't not
understand why this happens. What I need is a relable way to find the
seleted/active project of the solution.
Thanks in advance for any help,
Carsten
Mirko Matytschak - 25 Jun 2007 09:42 GMT
Hi Carsten,
maybe this might help:
System.Array solObjects = (Array)
applicationObject.ActiveSolutionProjects;
if (solObjects.Length < 1)
return; // No open project
Project project = (Project) solObjects.GetValue(0); // Mostly there is
only one entry in the array
The applicationObject is of Type _DTE and must be stored somewhere, while
the OnConnection method of the Connect class is running.
Best Regards
Mirko
http://www.netdataobjects.com
> Hi,
>
[quoted text clipped - 10 lines]
> Thanks in advance for any help,
> Carsten