Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / June 2007

Tip: Looking for answers? Try searching our database.

Active Project

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Carsten Grünzner - 22 Jun 2007 13:06 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.