This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 32886 - [Mono 3.12] Some WCF methods that do _not_ use "ref" parameters fail with "InvalidOperationException" during "ClientRuntimeChannel.EndProcess" when called via a ChannelFactory channel
Summary: [Mono 3.12] Some WCF methods that do _not_ use "ref" parameters fail with "In...
Status: RESOLVED FIXED
Alias: None
Product: Mono Installers
Classification: Mono
Component: General (show other bugs)
Version: 4.0.0
Hardware: PC All
: --- normal
Target Milestone: 4.2.0 (C6)
Assignee: Martin Baulig
URL:
Depends on:
Blocks:
 
Reported: 2015-08-07 23:21 UTC by Brendan Zagaeski (Xamarin Support)
Modified: 2015-10-05 22:32 UTC (History)
4 users (show)

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


Attachments
Test case (5.61 KB, application/zip)
2015-08-07 23:21 UTC, Brendan Zagaeski (Xamarin Support)
Details

Description Brendan Zagaeski (Xamarin Support) 2015-08-07 23:21:03 UTC
Created attachment 12420 [details]
Test case

Some WCF methods that do _not_ use "ref" parameters fail with "InvalidOperationException" during "ClientRuntimeChannel.EndProcess" when called via a ChannelFactory channel




## Regression status: regression caused by mono/8b10d9b + mono/87622fc (the fix for Bug 22129)

These changes were first released in Mono 3.12.0.


### Details

I can stop the problem if I comment out the following three lines from `System.ServiceModel/ClientRuntimeChannel.cs` and rebuild "System.ServiceModel.dll":

> if (p.Length == parameters.Length)
>	throw new InvalidOperationException ();
> Array.Copy (p, parameters, p.Length);




## Steps to reproduce

Build and run the attached test case. This is a tiny little console program that uses the W3 Schools' TempConvert example service.




## Results


### Debugging into the `EndProcess()` source

The two key lines are:

> object[] p = parameters;
> _processDelegate.EndInvoke (ref p, result);

After the first line, `p.Length` is 1.
After the second line, `p.Length` is 0.

The length of 0 causes an exception to be thrown later in the method:

> if (p.Length != parameters.Length)
> 	throw new InvalidOperationException ();


Maybe it is not strictly true that the number of input parameters must match the number of output parameters? Or perhaps the count of input parameters is incorrect? I don't think the input parameter for this service is a `ref` parameter, so maybe the count of input parameters is meant to be 0 rather than 1?



### Stack trace

> System.InvalidOperationException: Operation is not valid due to the current state of the object
>   at System.ServiceModel.MonoInternal.ClientRuntimeChannel.EndProcess (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters, IAsyncResult result) [0x00059] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr3/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.3/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:463 
>   at System.ServiceModel.ClientRealProxy.DoInvoke (IMessage inputMessage) [0x001f3] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr3/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.3/mcs/class/System.ServiceModel/System.ServiceModel/ClientRealProxy.cs:130 
>   at System.ServiceModel.ClientRealProxy.Invoke (IMessage inputMessage) [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr3/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.3/mcs/class/System.ServiceModel/System.ServiceModel/ClientRealProxy.cs:86 
>   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke (System.Runtime.Remoting.Proxies.RealProxy rp, IMessage msg, System.Exception& exc, System.Object[]& out_args) [0x0009c] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr3/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.3/mcs/class/corlib/System.Runtime.Remoting.Proxies/RealProxy.cs:194  




## Results on .NET on Windows

The test case builds and runs successfully. The WCF request completes, and the program outputs the return value from the service:

> The converted value is: 37
Comment 2 Martin Baulig 2015-08-18 14:03:00 UTC
Should be fixed now.
Comment 3 Miguel de Icaza [MSFT] 2015-08-19 10:39:46 UTC
Commits:

57ef8f9614266b3bccbafc0cc0ff1288f65e2c6d
dd40925cbb0f7829b836162a5477094094921909

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