Solved

Catch System.IO.FileLoadException at program startup

Posted on 2008-10-03
3
1,144 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
Comment Utility
0
 
LVL 10

Author Comment

by:Marcjev
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
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:…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now