[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Catch System.IO.FileLoadException at program startup

Posted on 2008-10-03
3
Medium Priority
?
1,168 Views
Last Modified: 2013-12-17
In my program I have a neat exception handler, which will catch every uncaught exception in my program and creates a file or even will mail me the error, including a callstack etc when something goes wrong.
But when one of the dll's does nog have the right version I get an 'System.IO.FileLoadException', which fires before the 'main' is entered and thus before I could install my exception handler.

How can I catch this 'FileLoadException' in code?
0
Comment
Question by:Marcjev
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 16

Expert Comment

by:CuteBug
ID: 22632177
0
 
LVL 10

Author Comment

by:Marcjev
ID: 22632269
No this blog does not help.
It points out all things I already have in my unhandled exceptionhandler. But this code is wired after you start the Main() of your application. If one of the DLL's your exe is depending on is not there or has a wrong version number, the FileLoadException is fired and this is done BEFORE you enter Main().

I want to fire some code which lives in the main executable, if one of the DLL's it's depending is not valid. I then want to report this fact in a nice logfile and exit gracefully.
0
 
LVL 20

Accepted Solution

by:
REA_ANDREW earned 1500 total points
ID: 22632349
You could create a Loading Program which simply, and is good practise to do so, creates a separate app domain for your program, and your program then runs inside this separate App Domain.  You would then be able to catch any expection which occurs in your target program before the Main().

Andrew
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

650 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