Exception not caught by Exception block in debug build, Xojo only

I have a shared method (full source of method) that reads a file and constructs an object out of it. If the file can’t be read then an IOException is raised.

The method has an exception block:

Exception Err As IOException If err.Message.Trim = "" Then err.Message = "The file could not be opened for reading." End If #pragma BreakOnExceptions Off Raise Err

The exception block is being called correctly whenever the BinaryStream used to read the file raises an IOException. Farther down the call stack there’s another Exception block that handles all types of exceptions with a generic error message:

Exception Err If Err IsA EndException Or Err IsA ThreadEndException Then Raise Err ' If I remove this line, it works again 'Handle the error

This worked fine yesterday. Today, for some reason, the exception block isn’t run at all and the exception causes the generic unhandled exception message box to pop up and the app to quit! If I remove the line comparing the exception to EndException or ThreadEndException, then it works again.

Even weirder, this only happens if it’s a debug build; if I build and then run the built app, everything works as expected. Also, if I add an event handler for App.UnhandledException (even if it’s empty), then it works again. Everything works as expected using RS2011r4.3.

What platform? And are you able to narrow it down at all?

The platform is Windows 7 x64. I’m not sure how to narrow it down more than I already have.

If I debug the app in a Windows XP VM, it works as expected, both if I’m debugging with Xojo in the VM or if I’m remotely debugging.

I’ve determined that only the latest revision of my code shows this behavior. All revisions up until this revision work as expected. Yet the only change in that revision was on one line in a completely unrelated part of the app! I’ve confirmed all other files identical with two different diff tools.

Have you tried simply wrapping your binarystream code in a try-catch block?

No, I haven’t; it shouldn’t be necessary as there is already an exception block to handle exceptions. That’s the whole problem: in the revision I linked to above, the catchall exception block is never being called. It seems isolated to the one particular revision, yet the diff between it and the revision immediately before shows that the only change I made was to another class in another directory.

The problem went away when I made some additional changes to a different part of the program, but I can pull the faulting revision and reproduce the glitch every time.

I’m tempted to think this is related in some way to the bug in this discussion, since they both seem related to using rbvcp projects in Xojo and both manifest themselves with no modifications to the source code.

I think it’s a bug in the runtime or the compiler, but have never been able to narrow it down to any simple test case. Do you know if this happens on OS X?

No, I’ve only tested on Windows.

Joe - not sure if this helps, but the other day I think I was seeing a bug in exception handling when an exception was triggered inside the App.UnhandledException() handler, this was on Win7x32

I see a problem on 2013r3.1 in OS X. “#pragma BreakOnExceptions Off” does not work correctly in the debugger, but it works correctly in the compiled application. It works correctly in 2013r1. My subscription just expired so I am not able to raise a feedback request for this.

This sounds like a different issue than exceptions ‘skipping’ a handler. Do you have an example project that you can upload somewhere?