Bug 13074 - Create task based service references (.NET 4.5 Profile)
Summary: Create task based service references (.NET 4.5 Profile)
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: WCF assemblies (show other bugs)
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2013-07-05 15:33 UTC by Neal
Modified: 2017-11-08 18:48 UTC (History)
6 users (show)

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


Description Neal 2013-07-05 15:33:09 UTC

I have a WCF service that has a Task<bool> return type in the service Interface.  It would be great if when adding a service reference if you could support the newer .NET 4.5 System.Threading.Task based methods so we can use the async await pattern.  Presently XS doesn't know how to handle these service references with task based methods.  As you're adding async await (.NET 4.5) support in the upcoming release which I'm in the beta channel testing, having this available would be great.

Comment 1 Sebastian 2014-07-04 11:42:32 UTC
Are there any news or plans about this topic? This feature is even useful if you want to create a proxy reference for soap services that should use async/ await instead of events.
Comment 2 github 2017-10-04 10:30:35 UTC
The lack of support for Task-based service references manifests itself in InvalidOperationExceptions when sharing generated code with .Net Framework, even though the Xamarin code doesn't call the async method. See e.g. https://bugzilla.xamarin.com/show_bug.cgi?id=46917

When creating a channel, the contract description is generated, and the operation description for the async method throws an InvalidOperationException: Operation 'FooAsync' contains a message with parameters. Strongly-typed or untyped message can be paired only with strongly-typed, untyped or void message.

The source of the exception is https://github.com/mono/mono/blob/0bcbe39b148bb498742fc68416f8293ccd350fb6/mcs/class/referencesource/System.ServiceModel/System/ServiceModel/Dispatcher/OperationFormatter.cs#L515

It seems likely that the root cause is that MessageDescription.IsTypedMessage is returning false for the return type System.Threading.Tasks.Task<MyTypedMessage>.
Comment 4 Victor Milovanov 2017-11-08 18:48:28 UTC
OH, BTW, the issue is not limited to Mac OS. Android has the same problem, and probably iOS too.

Note You need to log in before you can comment on or make changes to this bug.