Loading from GAC without all information

E

EmeraldShield

Ok, this is what I am trying to do...

I am trying to build a CheckForUpdates type feature into my app.

I want to enumerate all the versions of my DLL that are in the GAC (It has
to be in the GAC for reasons too long to go into here).
Then I just want to pull out the version numbers and call my site over SOAP
to see if any of them need updates.

It would appear that there are NO functions to enumerate all the versions of
your DLL installed. Or am I missing something?

This could will work if it is local, but not from the GAC.

Assembly vdb = Assembly.Load("MyDll.DLL");
Console.WriteLine(vdb.GetName().Version.ToString());
Console.WriteLine(vdb.GlobalAssemblyCache ? "GAC" : "Local");
Console.WriteLine(vdb.Location.ToString());

If I give it all the specifics of my DLL:

Assembly vdb = Assembly.Load("MyDLL, Version=3.21.3.18, Culture=Neutral,
PublicKeyToken=dfc935gge21123461");

It will load THAT ONE version, but no others. If I add an app.config file
to map them all together:

<bindingRedirect oldVersion="0.0.0.0-3.21" newVersion="3.21.3.18"/>

It still will not work.

How does Explorer do it? If I navigate to C:\windows\assembly I can see
each and every version of the DLL that is installed.

MyDll 3.10.x.x
MyDll 3.11.x.x
MyDll 3.13.x.x
MyDll 3.18.x.x

Whatever. I can't figure out how to do this...
 
W

Walter Wang [MSFT]

Hi,

I believe you can do this with GAC API. You can find an example in C# here:

#GAC API Interface - The Code Project - C# Programming
http://www.codeproject.com/csharp/GacApi.asp

Please also refer to following articles for more information on the GAC API:

#Junfeng Zhang's Windows Programming Notes : Fusion GAC API Samples
http://blogs.msdn.com/junfeng/articles/229648.aspx

#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

Please feel free to let me know if there's anything unclear. Thanks.

Sincerely,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top