Search:
Namespaces
Discussions
.NET v1.1
Feedback
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
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com