Bug 4511 - DuplexClientBase Channel Initialization Broken
Summary: DuplexClientBase Channel Initialization Broken
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: WCF assemblies ()
Version: 2.10.x
Hardware: PC Linux
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-04-18 16:56 UTC by nfouarge
Modified: 2012-09-20 00:34 UTC (History)
5 users (show)

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

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 GitHub or Developer Community 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:
Status:
RESOLVED FIXED

Description nfouarge 2012-04-18 16:56:21 UTC
This is a repost of https://bugzilla.novell.com/show_bug.cgi?id=702532

John Hargrove 2011-06-28 04:51:06 UTC
Created an attachment (id=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:
[reply] [-] 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?
[reply] [-] 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.
[reply] [-] 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
Comment 1 ch5oh 2012-09-03 11:30:58 UTC
> The actual failure is a cast from TransparentProxy into IClientChannel:

So what is the correct solution for this show-stopper? Should TransparentProxy just implement IClientChannel?

In another words: does anybody improve WCF now? And where is full WCF support (version 3.0 or 3.5 for example) on Mono's roadmap?
Comment 2 Martin Baulig 2012-09-20 00:34:39 UTC
Fixed; master commit b74e9eb.