Bug 702532 - DuplexClientBase Channel Initialization Broken
Summary: DuplexClientBase Channel Initialization Broken
Status: NEW
Alias: None
Product: Mono: Class Libraries
Classification: Mono
Component: WCF (show other bugs)
Version: 2.10.x
Hardware: x86-64 openSUSE 11.4
: P5 - None : Major
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-28 04:51 UTC by John Hargrove
Modified: 2011-11-12 19:15 UTC (History)
3 users (show)

See Also:
Found By: Development
Services Priority:
Business Priority:
Blocker: Yes
Marketing QA Status: ---
IT Deployment: ---


Attachments
Example Application To Reproduce (1.92 KB, text/plain)
2011-06-28 04:51 UTC, John Hargrove
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Hargrove 2011-06-28 04:51:06 UTC
Created attachment 436994 [details]
Example Application To Reproduce

Description of Problem:

I hesitated to post this report because the problem occurs in really the -MOST- basic usage of a duplex WCF service that I can fathom, and this has reportedly been supported for several versions. I am entirely open to the idea that my energy drink had some kind of hallucinogen in it.

As of Mono 2.10.2, I cannot successfully implement a duplex WCF client/server. The client fails to initialize when attempting to create the underlying communication channel. The error is an InvalidCastException thrown during ClientBase<T>.CreateChannel().

I have isolated this problem to DuplexClientBase<T>, as I can successfully initialize a simplex client using ClientBase<T>, as well as manually create the channel by calling DuplexChannelFactory<T>.CreateChannel() and bypassing the DuplexClientBase<T> helper all together.


Steps to reproduce the problem:
I have provided a very basic example:

* A service contract (ITestContract) which defines a single addition operation, and is associated with a callback contract (ITestCallbackContract)
* A callback contract (ITestCallbackContract) that defines a simple operation to send a message back to the client side.
* An implementation of the server (TestServer) and the callback object (TestCallbackClient)

The setup is dead simple. net-tcp binding, bound to local interface on port 15201.



Actual Results:
Unhandled Exception: System.InvalidCastException: Cannot cast from source type to destination type.
  at System.ServiceModel.ClientBase`1[Jgh.Test.Program+ITestContract].get_InnerChannel () [0x00000] in <filename unknown>:0
  at System.ServiceModel.ClientBase`1[Jgh.Test.Program+ITestContract].Open () [0x00000] in <filename unknown>:0
  at Jgh.Test.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0

Expected Results:
Callback says: Adding 50 and 25 is 75!
Adding server result: 75

How often does this happen? 

This examples works out of box on .NET, but fails identically with Mono 2.10.2 on both Windows 7 x64 and OpenSUSE 11.4 x86-64. I have not tested other platforms or other mono versions.

Additional Information:
Comment 1 Viktar Siarheichyk 2011-11-09 14:30:58 UTC
I have encountered the same behavior on Debian Wheezy with Mono 2.10.5 from the experimental distribution. Any update on this bug?
Comment 2 Viktar Siarheichyk 2011-11-09 16:57:19 UTC
(In reply to comment #1)
> I have encountered the same behavior on Debian Wheezy with Mono 2.10.5 from the
> experimental distribution. Any update on this bug?

The same behavior on Mac OS X 10.6.8, Mono 2.10.6.
Comment 3 Miguel de Icaza 2011-11-10 04:20:11 UTC
The actual failure is a cast from TransparentProxy into IClientChannel:

Unhandled Exception: System.InvalidCastException: Unable to cast object of type 'System.Runtime.Remoting.Proxies.TransparentProxy' to type 'System.ServiceModel.IClientChannel'.
  at System.ServiceModel.ClientBase`1[Jgh.Test.Program+ITestContract].get_InnerChannel () [0x00028] in /private/tmp/monobuild/build/BUILD/mono-2.10.6/mcs/class/System.ServiceModel/System.ServiceModel/ClientBase.cs:209 
  at System.ServiceModel.ClientBase`1[Jgh.Test.Program+ITestContract].Open () [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.6/mcs/class/System.ServiceModel/System.ServiceModel/ClientBase.cs:311 
  at Jgh.Test.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidCastException: Unable to cast object of type 'System.Runtime.Remoting.Proxies.TransparentProxy' to type 'System.ServiceModel.IClientChannel'.
  at System.ServiceModel.ClientBase`1[Jgh.Test.Program+ITestContract].get_InnerChannel () [0x00028] in /private/tmp/monobuild/build/BUILD/mono-2.10.6/mcs/class/System.ServiceModel/System.ServiceModel/ClientBase.cs:209 
  at System.ServiceModel.ClientBase`1[Jgh.Test.Program+ITestContract].Open () [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.6/mcs/class/System.ServiceModel/System.ServiceModel/ClientBase.cs:311 
  at Jgh.Test.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0