Solved

How to determine if assembly exists before attempting load using Reflection

Posted on 2011-03-13
4
786 Views
Last Modified: 2012-05-11
We are using Reflection to load an assembly when an application first starts up.  How would I determine if the assembly exists before executing Reflection.Assembly.Load?
0
Comment
Question by:MEINMEL
  • 2
  • 2
4 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 35123526
What type of assembly are you trying to load?  Is it stored in the GAC, or a separate DLL?  If it is a separate DLL, you should be able to use System.IO.File.Exists(path) to find out if the file exists.  
0
 

Author Closing Comment

by:MEINMEL
ID: 35129666
That's what I was originally going to do - I just wondered if there was another option.  Thanks
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 35129709
You could attach a handle to AppDomain.CurrentDomain.AssemblyResolve, which is called when the assembly can't be found, so that you can provide the assembly, but that is a different approach than what you are describing.
0
 

Author Comment

by:MEINMEL
ID: 35129724
Thank you very much!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question