Late Bind GAC Assembly ?

  • Thread starter Thread starter localhost
  • Start date Start date
L

localhost

I have an assembly that needs to poll the GAC for the existence of
another GAC'd assembly, and if version 1.4 exists, load 1.4, but use
1.5 if it is available.

Where is a good code example of how to make that happen?

Thanks.
 
Hello,

Thanks for your post. As I understand, you want to dynamically load a GAC
assembly. Please correct me if there is any misunderstanding. I'd like to
share the following information with you:

1. We are able to use Assembly.Load to load assembly from the GAC. In
addition, the assembly reference must be fully-qualified (name, version,
public key token, culture). For example:

"System.Data, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"

2. Each version of a specific assembly in GAC is in its own folder, for
example:

Directory of C:\WINDOWS\assembly\GAC\System.Data

11/04/2003 11:38 AM <DIR> .
11/04/2003 11:38 AM <DIR> ..
11/04/2003 11:38 AM <DIR> 1.0.3300.0__b77a5c561934e089
09/10/2003 07:44 PM <DIR> 1.0.5000.0__b77a5c561934e089

I suggest that you can use Directory.GetDirectories to get the list of
versions:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemiodirectoryclassgetdirectoriestopic.asp

Please feel free to let me know if you have any problems or concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
I suggest that you can use Directory.GetDirectories to get the list of
versions:

Really? I thought looking directly at the GAC directory structure was
a big no-no, and that the recommended way of listing the GAC content
was with the Fusion APIs (Q317540). Depending on GAC implementation
details like this is IMO asking for trouble, especially since it
already seems to have changed somewhat in Whidbey.



Mattias
 
Hi Mattias,

Thanks for your information. You are correct that using IAssemblyEnum is
better than Directory.GetDirectories.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top