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 / Windows Forms / Design Time / May 2005

Tip: Looking for answers? Try searching our database.

how to get list of assemblies referenced by the current project

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mnowosad - 18 May 2005 03:57 GMT
I am looking for a way, during design-time, to be able to access all
assemblies that were added as references to the currently selected project.

That would allow me, for instance, to open a control editor and populate a
list box with the names of all assemblies referenced by the project that the
control is part of.

I checked the available design-time services like ITypeResolutionService and
IReferenceService and none of them seem to be useful for that purpose.

So how I can do it?

Thanks,
Marcos
Francisco Padron - 22 May 2005 01:12 GMT
I think you have to go to the Visual Studio IDE automation interfaces
(EnvDTE.DTE) to get this.

I found this code in MSDN (sorry about the VB code, too lazy to translate):

Imports VSLangProj
Sub ListReferences()
  ' Retrieve the VSProject object.
  Dim theVSProject As VSProject = _
     CType(DTE.Solution.Projects.Item(1).Object, VSProject)

  ' Retrieve the references collection.
  Dim refs As References = theVSProject.References

  ' Create a string list of the reference names.
  Dim refList As String = ""
  Dim aRef As Reference
  For Each aRef In refs
     refList &= aRef.Identity & ControlChars.CrLf
  Next
  MsgBox(refList)
End Sub

I think this code is for an add-in, however you can obtain the DTE from any
designer/control using GetService:

EnvDTE.DTE dte = (EnvDTE.DTE) Component.Site.GetService(typeof(EnvDTE.DTE));

I hope this helps.

Signature

Francisco Padron
www.chartfx.com

>I am looking for a way, during design-time, to be able to access all
> assemblies that were added as references to the currently selected
[quoted text clipped - 13 lines]
> Thanks,
> Marcos
mnowosad - 23 May 2005 18:54 GMT
Thanks for the answer. I actually had already found a similar code in the web
and it worked as expected. However, you gave me a better way to access the
DTE through the designer. I originally was making this Interop COM call:

EnvDTE.DTE dte = (EnvDTE.DTE)
System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.7.1");

Instead, after your suggestion, I am using this code, which is much more
compliant to the .NET Component design-time framework:

EnvDTE.DTE dte = (EnvDTE.DTE) Component.Site.GetService(typeof(EnvDTE.DTE));

Thanks again,
Marcos

> I think you have to go to the Visual Studio IDE automation interfaces
> (EnvDTE.DTE) to get this.
[quoted text clipped - 41 lines]
> > Thanks,
> > Marcos

Rate this thread:







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.