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 / .NET Framework / New Users / September 2006

Tip: Looking for answers? Try searching our database.

frameworrk and GAC components

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Emby - 13 Sep 2006 01:37 GMT
I need to present a list of assemblies as potential references, similar to
(but less sophisticated than) the Visual Studio project references dialog.

The reason for this is that my app supports scripting by dynamically
compiling VB.NET code (via CodeDom.Compiler), and I want to provide for the
selection of references required by the user's script project.

So I want the app to present a list of assemblies installed in the GAC,
including available framework system assemblies (e.g., System.Xml,
System.Data, System.Windows.Forms, etc.).

Is there a managed mechanism to enumerate GAC assemblies? In searching
about, I've found "DOC: Global Assembly Cache (GAC) APIs Are Not Documented
in the .NET Framework Software Development Kit (SDK) Documentation"
(http://support.microsoft.com/default.aspx?scid=kb;en-us;317540). But this
looks like C++, and I was hoping for a C# solution (I could even live
with/translate VB.NET).

Anyone have an idea of how to accomplish this?

Thanks
Mattias Sjögren - 13 Sep 2006 05:00 GMT
>Is there a managed mechanism to enumerate GAC assemblies?

Not in the framework, not. But you can call those COM APIs from C# if
you want.

But the GAC has nothing to do with compile time references. It's only
used when loading the assembly at runtime. The VS Add Reference
dialog, for example, does not list the contents of the GAC.

Mattias

Signature

Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Emby - 13 Sep 2006 12:47 GMT
Thanks Mattias,

So what does the VS Add References dialog use? How can I get the list of
available references?

My dialog has a Browse button (for adding references not in the GAC), but if
you navigate to the GAC with the file open dialog, you get the same "funky"
view of the GAC that Windows Explorer shows (provided by SHFusion.dll), and
you can't actually select anything in the dialog.

Emby

>>Is there a managed mechanism to enumerate GAC assemblies?
>
[quoted text clipped - 6 lines]
>
> Mattias
Mattias Sjögren - 13 Sep 2006 21:40 GMT
>So what does the VS Add References dialog use?

The framework directory (%WINDIR%\Microosft.NET\Framework\vX.Y.ZZZZ)
plus any additional directories listed in the Registry, as explained
in this article

http://support.microsoft.com/?kbid=306149

Mattias

Signature

Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Emby - 14 Sep 2006 12:20 GMT
Thank you Mattias,

FYI, I've poked around a bit more, and here's what I've found:

HKLM\SOFTWARE\Microsoft\.NETFramework\InstallRoot
Gives the root folder of all installed framework versions; append the
version (e.g., "\v2.0.50727 ") to get the folder where a given framework's
dll files are installed

As the article notes:
HKLM\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders (and HKCU)

But I also found:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx
This yields other VS components (like PIA's) and other public assemblies.

I have one more related question, which I'll post in a separate message - I
basically want to know if there is an easy/quick way to programmatically
identify a .NET assembly (EXE or DLL). One of the assembly folders you get
from the registry can have many files, but only 1 or 2 of which are .NET
assemblies. Is there a way to find them (other than trying to load each as
an assembly)?

Thanks so much for your help.

Emby

> >So what does the VS Add References dialog use?
>
[quoted text clipped - 5 lines]
>
> Mattias

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.