.NETGURU
Iterating through Global Assembly Cache (GAC) ...
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.clr.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Bob (VIP)
Can anyone explain whether I can programmatically iterate through
Global Assembly Cache (GAC) and discover the assemblies that support
the certain interface? I know that I can discover the assemblies
that support the certain interface located in specified (let say
plug in) directory, but I can't find any way to iterate through
GAC. Please help. Thanks.
Reply to this message...
 
    
Robert Jordan
Bob wrote:

[Original message clipped]

http://www.msjogren.net/dotnet/eng/samples/dotnet_gactool.asp

bye
Rob
Reply to this message...
 
    
Bob (VIP)
Thanks for your reply. But now the question is whether I can use undocumented
interface IAssemblyEnum? The following KB article is extremely confusing:
http://support.microsoft.com/?kbid=317540

I quote "MORE INFORMATION" section from this article:

"CAUTION: Do not use these APIs in your application to perform assembly
binds or to test for the presence of assemblies or other run time,
development, or design-time operations. Only administrative tools and setup
programs must use these APIs. If you use the GAC, this directly exposes your
application to assembly binding fragility or may cause your application to
work improperly on future versions of the .NET Framework."

.... then it contradicts itself

"The only supported method to access assemblies in the GAC is through the
APIs that are documented in this article."

.... and again

"Use the GAC API in the following scenarios:
When you enumerate assemblies that are available in the GAC."

So the question remains can I use in my application IAssemblyEnum interface
to enumerate assemblies that are available in the GAC? Will these API be
supported in the next version of .NET framework? Thanks.

"Robert Jordan" wrote:

[Original message clipped]

Reply to this message...
 
    
Robert Jordan
Hi Bob,

[Original message clipped]

So it's documented ;-)

[Original message clipped]

They mean: don't build you *own* assembly loader/binder
using this API.

[Original message clipped]

.... but don't load them using Assembly.LoadFrom(filename)
from the GAC directory, for example.

[Original message clipped]

As far I understood, yes.

bye
Rob
Reply to this message...
 
    
Alicia Li (VIP)
Are you trying to iterating the files directly under GAC? When you look at
the GAC directory in explore, looks like all the assembly files are
directly under GAC directory, but actually it's not. If you to go the GAC
directory in a dos window, you can see that GAC contains subdirectories and
each assembly file has its own individual subdirectory. The reason that GAC
directory looks differently from explore is that you actually look at
files from fusion shell, which makes GAC information easy to read.

If you iterating the files directly under GAC directory, it will fail for
could not find files. You can iterating throw the subdirectoroes though.

Thanks
Alicia

Reply to this message...
 
    
Alicia Li (VIP)
After my first reply, I realized that I probably misunderstood the original
question. Sorry about that.

If you want to iterate the assemblies under GAC and load them, please never
iterate the phsical files under GAC subdirectory. It could cause you all
kinds of problems.

There are two suggestions:
1. use Gacutil.exe sdk tool, "gacutil -l" will dump all the assemblies
installed in GAC. You can parse the output.
2. Use fusion unmanaged IAssemblyEnum Interface. I may be able to find a
managed wrapper. If I can, I will post the info to this thread later.

Thanks
Alicia

Reply to this message...
 
    
Alicia Li (VIP)
Okay, I got the managed wrapper for fusion unmanaged IAssemblyEnum APIs:
http://blogs.msdn.com/junfeng/archive/2004/09/14/229653.aspx

Thanks
Alicia

Reply to this message...
 
 
System.Reflection.Assembly




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification