Bug 3338 - MonoDevelop always breaks on exceptions in methods called by Delegate.BeginInvoke
Summary: MonoDevelop always breaks on exceptions in methods called by Delegate.BeginIn...
Alias: None
Product: Runtime
Classification: Mono
Component: Debugger ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
: 10274 ()
Depends on:
Reported: 2012-02-09 18:10 UTC by Rolf Bjarne Kvinge [MSFT]
Modified: 2013-09-16 15:31 UTC (History)
7 users (show)

Is this bug a regression?: ---
Last known good build:

test case (7.98 KB, application/zip)
2012-02-09 18:10 UTC, Rolf Bjarne Kvinge [MSFT]

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Rolf Bjarne Kvinge [MSFT] 2012-02-09 18:10:27 UTC
Created attachment 1338 [details]
test case


Open the test project and run it. MonoDevelop will break on the exception (and there is no way to configure MonoDevelop to not break on it).
Comment 1 Mikayla Hutchinson [MSFT] 2012-02-09 19:22:35 UTC
BeginInvoke/EndInvoke don't work that way. From MSDN docs for BeginInvoke: "Exceptions within the delegate method are considered untrapped and will be sent to the application's untrapped exception handler."
Comment 2 Mikayla Hutchinson [MSFT] 2012-02-09 19:29:40 UTC
My mistake, didn't see the callback using EndInvoke.

This appears to be an issue in sdb's detection of whether exceptions are handled.
Comment 3 Zoltan Varga 2012-02-10 19:26:40 UTC
This is caused by this block of code in mini-exceptions.c:

			// Treat exceptions that are "handled" by mono_runtime_invoke() as unhandled.
			// See bug #669836.
			if (ji && ji->method->wrapper_type == MONO_WRAPPER_RUNTIME_INVOKE)
				mono_debugger_agent_handle_exception (obj, ctx, NULL);
				mono_debugger_agent_handle_exception (obj, ctx, &ctx_cp);

The referenced bug is this:
Comment 4 Adam Kemp 2012-03-04 02:47:36 UTC
This is preventing me from running some automated tests in the debugger (the tests are explicitly testing exceptions thrown in asynchronous calls).
Comment 5 Felix Collins 2012-05-20 23:12:30 UTC
Can this be raised in importance please as it is a real problem for working with WCF web services...
Comment 6 Felix Collins 2012-07-22 17:37:10 UTC
Is there any progress on this issue? It is still causing major pain in my project. When I run in the debugger I have to be prepared to frequently cancel the exception dialogue and continue execution every time an exception is thrown in a web service thread (for example if the server is down) even though I handle those exceptions in user code...
Comment 7 Zoltan Varga 2012-07-22 19:32:34 UTC
The issue isa bit hard to fix.we could revert the change which is causing this problem but that would cause the bug fixed by that change to resurface again.
Comment 8 Zoltan Varga 2012-10-11 10:11:36 UTC
I can reproduce this by changing the testcase to:

			NSTimer.CreateScheduledTimer(new TimeSpan(0, 0, 3), delegate {
				Console.WriteLine ("A");
				//this code will hang the UI thread on the next run loop iteration
					throw new Exception("ff");
				catch(Exception) {
				Console.WriteLine ("B");
Comment 9 Zoltan Varga 2013-05-13 10:57:55 UTC
Fixed in mono master(35421ffb4361a3e3fb2e389b4f5e4c514d4dcb83), 2.10 (bbac22e90896c842341f7d02ec50e235d54c4d29), and mobile-master(616707d745ec10787e8f1c3b939b32de2382502f).
Comment 10 Zoltan Varga 2013-09-16 15:20:30 UTC
Comment 11 Zoltan Varga 2013-09-16 15:31:09 UTC
*** Bug 10274 has been marked as a duplicate of this bug. ***