Solved

How to determine if assembly exists before attempting load using Reflection

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now