Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I determine if a referenced assembly is installed?

Status
Not open for further replies.

dalchri

Programmer
Apr 19, 2002
608
US
I plan to have optional components (dll files) in my app and would like to know how I can tell if they are installed. I don't want to look for a file name because it might be the wrong version. I don't want to limit myself to the same folder as the executing assembly because I know .NET might find the assembly in the GAC.

I know that I can get the references through Assembly.GetReferencedAssemblies() but what I don't know is what to do with them.

The only solution that I can see is to pass the AssemblyName array off to Assembly.Load and then eat the exception that occurs when .NET cannot find them. I'd rather not have the lag that this would entail though because all I am doing is enabling and disabling parts of the UI based on what is installed.

I've also tried binding to the AppDomain.AssemblyResolve event but this only seems to fire when satellite assemblies are resolved, not when external class libraries are resolved contrary to the documentation.
 
You can look in the virtual folder c:\Winnt\assembly to see if it's there. It'll probably be in the registry somewhere, too.

Chip H.


____________________________________________________________________
Click here to learn Ways to help with Tsunami Relief
If you want to get the best response to a question, please read FAQ222-2244 first
 
Seems like the standard approach would be to commit to a folder such as the same folder as the executable, load all the assemblies found there, and then verify which optional components were installed based on that list.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top