I have an installer program that needs to know whether PIAs are already
installed in the GAC so that I won't install them twice. So the question is
how can we programmatically tell whether the GAC contains a particular
assembly?

References:

I found these articles:

Assembly.Load Method (AssemblyName)
ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfsystemreflectionassemblyclassloadtopic1.htm

Assembly.LoadWithPartialName
ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemReflectionAssemblyClassLoadWithPartialNameTopic.htm

How the Runtime Locates Assemblies
ms-help://MS.VSCC/MS.MSDNVS/cpguide/html/cpconhowruntimelocatesassemblies.htm

The third article says that if you want to load an assembly from the GAC as
opposed to just from the app directory, you need to call
Assembly.LoadWithPartialName rather than Assembly.Load.

This is the best answer I've found so far: try to load the assembly then if
that fails, then the assembly isn't there. This is lame, however. We don't
want to load the assembly, we just want to know whether it exists or not.


---------------------
Sam Gentile
.NET Consultant
Co-author: Wrox Visual C++ .NET: A primer for C++ developers
BLOG: http://radio.weblogs.com/0105852/
http://www.project-inspiration.com/sgentile/DotNet.htm
http://www.project-inspiration.com/sgentile/
---------------------------




_________________________________________________________________
Join the world�s largest e-mail service with MSN Hotmail.
http://www.hotmail.com

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to