Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 870
  • Last Modified:

How to determine if assembly exists before attempting load using Reflection

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
MEINMEL
Asked:
MEINMEL
  • 2
  • 2
1 Solution
 
Bob LearnedCommented:
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
 
MEINMELAuthor Commented:
That's what I was originally going to do - I just wondered if there was another option.  Thanks
0
 
Bob LearnedCommented:
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
 
MEINMELAuthor Commented:
Thank you very much!
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now