C# – Console Application – Can’t Catch Unhandled Exception


I have written a very simple C# Console Application which will open a Crystal Report, refresh it and save it as a PDF to a specified location.

When running within VS2005 everything runs fine; the pdf file is generated as expected. When I copy the .exe to my root C: drive and run it from the command line I get a dialog box stating that "CrystalGenerator has stopped working" – but the pdf file is still generated!
Looking up possible causes of this dialog indicate that an Unhandled Exception has occured but the entire contents of the Main method is contained within a try/catch so that can't be my problem.

Looking in the event log I see a number of entries stating "The substitution string for insert index (%1) could not be found" but cannot find a sensible explanation of what this means.

The upside is that if I copy the file to a box running Server 2003 (where it is intended to run) the command runs without error – but I want to know why the app misbehaves on Vista and how to resolve it.

Thanks in advance.

Best Solution

Does it work if you run the app from an elevated command prompt (WinKey followed by pressing cmd followed by Ctrl+Shift+Return)?

It might be that one of processes you are calling requires elevation.