I am currently migrating a large C# application to 64-bits and I have encountered a kind of weird problem. In 32-bits all is working fine, but in 64-bits, it seems like like handled exceptions are thrown a second time and make the application crash. This situation appears in a piece of code similar to the one below. The FileNotFoundException is caught as expected because the file does not exist, but then, the app crashes in the catch block after the message box is dismissed with the same FileNotFoundException. I did not reproduce this behaviour in a smaller application, so I am trying to gradually remove some code from our app to try isolate where this problem is comming from. While I do this, I was wondering if anyone might have seen such a problem ?
many thanks
try
{
// Try to open a non existing file throws a file not found exception
FileStream fs = new FileStream("some_file_that_doesnt_exist",
FileMode.Open,
FileAccess.Read);
}
catch(FileNotFoundException ex)
{
// Exception caught as expected.
MessageBox.Show(ex.Message);
// Message box is shown, but the app crashes just after the call returns with the same file not found exception.
}