Solved

How to determine if assembly exists before attempting load using Reflection

Posted on 2011-03-13
4
796 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

789 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