?
Solved

Catch System.IO.FileLoadException at program startup

Posted on 2008-10-03
3
Medium Priority
?
1,177 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
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Screencast - Getting to Know the Pipeline
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

864 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