?
Solved

Catch System.IO.FileLoadException at program startup

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

764 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