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:
System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.7.1");
"Francisco Padron" wrote:
> 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:
>
>
>
>
> I hope this helps.
>
> --
> Francisco Padron
>
www.chartfx.com >
>
> "mnowosad" <mnowosad@discussions.microsoft.com> wrote in message
> news:49A3AC5C-CC92-4F0B-84E2-93B2ED54F256@microsoft.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
> > 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
>
>