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
Solved

Catch System.IO.FileLoadException at program startup

Posted on 2008-10-03
3
1,149 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 500 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

766 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