473,505 Members | 16,332 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Testing for references availability programmatically?

Hi,

I'd like to do the following:

My main application is a .exe, that uses a .dll included as a
reference in the project.

I'd like to know if it's possible for the .exe to physically test the
presence of the .dll in its directory (i.e. theFile.exists).
So far, instructions to that extent have failed, because the Framework
throws an exception before any code is executed.

So, can I include such a check in the .exe, or do I have to catch the
exception first thing? I don't think that would work, since as I've
said the Framework crashes before, apparently, any code is executed in
the .exe

Thanks for any answer.
Oct 15 '06 #1
2 1072
Phoenix <no@spam.comwrote in news:2693j29ebnatbt2jn85llb2af3r3e9e3hh@
4ax.com:
I'd like to know if it's possible for the .exe to physically test the
presence of the .dll in its directory (i.e. theFile.exists).
So far, instructions to that extent have failed, because the Framework
throws an exception before any code is executed.

So, can I include such a check in the .exe, or do I have to catch the
exception first thing? I don't think that would work, since as I've
said the Framework crashes before, apparently, any code is executed in
the .exe
Yes it's possible - take a look at the System.Reflection namespace.

The reflection namespace provides function to dynamically load DLLs from
disk. Once you have the DLL loaded, you can scan through the assembly to
see if the proper classes are in place, etc.
Oct 15 '06 #2
Also note: you don't need to hard code the assemblies: look at:
Assembly.GetExecutingAssembly().GetReferencedAssem blies()
This gives you the "what I reference" as AssemblyName instances,
suitable for passing to Assembly.Load()... so you can call that and see
what you get back. Each only loads once, so this is safe to call. You
may wish to resursively check each as you load it, but watch out that
the 2 main MS libs are circularly referenced (each references the
other), so watch you don't get into an infinite loop... for instance,
keep a list of checked assemblies, and exclude references you have
already checked.

Also - this checking code *must* preceed the first attempt to use them.
Additionally, you cannot use types from the referenced assemblies in
the same method, as JIT works method-by-method.

Marc

Oct 15 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2817
by: Dan Williams | last post by:
Can anyone tell me how to go about creating my own custom ASP page that can show several different peoples availability from their Outlook/Exchange 2000 calendars? I don't want to have to ask...
2
1649
by: Martin RAYROLE | last post by:
Hi folks, Does somebody know how to test the availability of a font on the browser platform ? Thanks for your help Martin
24
2785
by: MLH | last post by:
Most people tell me I only need 3 references. It seems that many of my problems are related to references. I don't know what a reference is, quite frankly. I wish that, instead of about 200...
18
3752
by: Praveen Ramesh | last post by:
Hi, Is there any way to add the @Assembly reference to the aspx files programmatically from inside a custom control (when it gets dropped on to the page from the toolbox)? I have a custom...
2
4704
by: Popoxinhxan | last post by:
Could anyone give me a guide or example of how to test the web service Here is my web service but i don't know how to write the test for it public class Service{ private string m_ERR_NO_LISTING=...
12
1197
by: Bo Peng | last post by:
Dear list, Is there a better way than doing try: import aModule except: has_aModule = False else: has_aModule = True
2
2802
by: Lapu-Lapu | last post by:
I have authored a web service using ASP 2.0. The web services return objects that use generics and that also contain circular references. Programmatically, everything works well, as long as you...
2
2329
by: chris fellows | last post by:
Can someone tell me if .NET 2.0 framework has a namespace to enable project references to be changed programmatically? My C# project files are stored in source control with DLL references but I...
0
7218
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7307
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7370
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5035
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4701
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1532
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.