If you can modify the code and redeploy:
- Create a new startup class (one with Main()), make sure you choose that class in project properties
- Ensure there are no "using" and external references from your startup class outside System
- put a try/catch around a call to your previous startup class's Main
print out the exception and all inner exceptions in a message box (or debug log)
public class MyNewEntryClass{
public static void Main(){
try{
MyPreviousEntryClass.Main();
} catch (Exception x){
Exception ix = x;
while (ix!=null){
MessageBox.Show("Exception: "+ix);
ix=ix.InnerException;
}
}
}
}
EDIT: I see your exception is coming from a message handler. The above code edit can (and should) be applied to all entry methods, which includes all event handlers that handle events from outside your code. The above crash screen could show up for exceptions in various handlers, asynchronously executed code. For example a button handler with asynchrounous calls should have two try/catches to prevent the crash window from showing up:
private void Button_Clicked(object sender, EventArgs arg){
try{
Action<string> asyncCall = (s)=>{
try{
//...exception here will cause crash
// as it's not handled in Button_Clicked
} catch (Exception xOnAsyncThread){
}
};
asyncCall.BeginInvoke("outahere",null,null);
} catch (Exception xOnUIThread){
}
}
The above statement is true for windows message handling as well - it's just another event handler for an outside event
If you can't modify the code and redeploy use Sysinternals Process Monitor:
http://technet.microsoft.com/en-us/sysinternals/bb896645
Configure it to monitor your app and highlight file not found events (see their docs for details)
If ProcessMonitor is too much copy all the contents from the exception message and go by exclusion - the ones that are loaded aren't the problem