.NET Framework Bookmark and Share   
 index > 64-Bit .NET Framework Development > Handled exception crashes an application after on a call that shouldn't throw this type of exception.
 

Handled exception crashes an application after on a call that shouldn't throw this type of exception.

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.
}
dbourassa
I have actually isolated the problem and it was totally unrelated. There was a marshalling error that cause problems in 64-bits. Found out that the problem occurred when a webbrowser control was repainted. Anyway, thanks for the help, it got me looking in another, better direction.

David
dbourassa
Can you post your real code? I'd suspect that you're trying to use the FileStream somewhere after the catch block, and the second usage of it is throwing a new (unhandled) FileNotFoundException.

You could try checking the stack trace of the exception that's not being handled, and see exactly which line is raising it.

Reed Copsey, Jr. - http://reedcopsey.com
Reed Copsey, Jr.
I have actually isolated the problem and it was totally unrelated. There was a marshalling error that cause problems in 64-bits. Found out that the problem occurred when a webbrowser control was repainted. Anyway, thanks for the help, it got me looking in another, better direction.

David
dbourassa

You can use google to search for other answers

Custom Search

More Threads

• aximp fails to generate a wrapper for a 64 bit ocx
• Itaniun & Managed C++ Extensions: Unresolved token 'Sleep'
• VS 2005 hardware: AMD or Intel?
• CAPICOM for 64 bitness
• Attempted to load a 64-bit assembly on a 32-bit platform. Use ReflectionOnlyLoad() instead if trying to load for reflect
• A generic error occured in GDI+
• Deployment setup project cannot access 64bit registry
• Weird Visual Studion 2008 behavior on windows 7 x64
• Performance issue in DataRow updation.
• Cannot install .net 2003 on AMD Atholon 64bit 3000