Bug 564 - Referenced WCF throws InvalidOperationException
Summary: Referenced WCF throws InvalidOperationException
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 4.x
Hardware: Other Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2011-08-31 07:45 UTC by René Ruppert
Modified: 2011-09-14 07:05 UTC (History)
3 users (show)

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

MonoDevelop 2.6 Project using WCF and Monotouch (17.85 KB, application/x-zip-compressed)
2011-08-31 07:45 UTC, René Ruppert

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 René Ruppert 2011-08-31 07:45:29 UTC
Created attachment 222 [details]
MonoDevelop 2.6 Project using WCF and Monotouch

I'm referencing our test WCF service and get an InvalidOperationException.

There are two other issues related to this. For details, see here:

and here:

The exception I get:
31.08.11 13:36:38,079 UIKitApplication:com.yourcompany.wcfmonotouch[0x62ef]: Unhandled Exception: System.InvalidOperationException: MonoTouch does not support dynamic proxy code generation. Override this method or its caller to return specific client proxy instance

My assumption:
It looks like I'm doing something wrong but the exception does not really tell me what to do and how to solve it. So if you can help me out it would be fine but adding a more detailed information what to do might be the fix for this "bug".

Attached find a demo project demonstrating the issue. Note that this demo project required me to work around bug 563 and use a Reference.cs generated by Visual Studio.
Comment 1 Sebastien Pouliot 2011-08-31 14:55:57 UTC
You are ending up in ChannelFactory<TChannel>.CreateChannel [1]. This code has a check before attempting to use features (code generation) that is not available without JIT support (i.e. it's not possible to JIT on iOS devices) [2].

So the InvalidOperationException is "normal" in this case (with the attached generated code). 

[1] mono/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory_1.cs
[2] http://ios.xamarin.com/Documentation/Limitations
Comment 2 René Ruppert 2011-09-14 07:05:44 UTC
Okay, thanks. But what do I have to do to be able to consume the service? I know that comsuming services is possible from MT, so what is wrong with my code in this specific case?