Bug 4472 - Throw statement in catch makes catching timeout on WCF impossible
Summary: Throw statement in catch makes catching timeout on WCF impossible
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 5.2
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-04-17 03:17 UTC by Edwin Klesman
Modified: 2012-04-19 02:54 UTC (History)
2 users (show)

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

screenshot of the mentioned code (55.51 KB, image/png)
2012-04-17 03:17 UTC, Edwin Klesman

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 Developer Community or GitHub 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 Edwin Klesman 2012-04-17 03:17:15 UTC
Created attachment 1686 [details]
screenshot of the mentioned code

During testing I noticed app crashes because our call to a WCF experienced a timeout (GSM network issues during the time which made the data transfer slower then usual). We could not catch the timeout (which we set using the serviceClient.InnerChannel.OperationTimeout property) and this made the app crash.

Debugging showed that in the ClientRuntimeChannel.cs (in the dir <monotouch dir>/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/) on line 485 the code uses a "throws" statement in the catch part of a try..catch statement which makes it impossible to hook into this error.

We commented out this statement and were able to catch the error since then and at least represent the user with a neat alert.

Please remove the throw statement (which does not use the required expression parameter) so errors can be caught in custom code.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2012-04-18 10:16:00 UTC
Any WCF exception is passed to the completed callback, in the EventArgs.Error property.

Here is an example of how to check for errors:

Comment 2 Edwin Klesman 2012-04-18 10:31:48 UTC
Then, perhaps the combination of seperate threads (async servicecall) and the service's channel with an execption make it so that my code doesn't receive a callback?

Normally we always retrieve a callback and in that i check for the error. I am using a client that was generated from the WCF service and check for errors like this:

void HandleServiceClientSendRequestCompleted (object sender, System.ComponentModel.AsyncCompletedEventArgs e)
			if (e.Error == null)
				Console.WriteLine("Dispatch success event ");
				RequestSuccesvolVerzondenEvent(this, new EventArgs() );
				ThrowServiceCallError(); // logs the error and sends a message so we can show an alert for the user

But if the callback never occurs (and the service isn't reached - we checked) there might be situations that aren't handled correctly.
I'll leave the status the same but i cannot get a callback with the usage of throw in the catch statement...
Comment 3 Rolf Bjarne Kvinge [MSFT] 2012-04-18 17:18:42 UTC
Can you add a test case I can try out?
Comment 4 Edwin Klesman 2012-04-19 02:54:26 UTC
I'll check if i can define one and will notify you when / if i succeed.