Bugzilla – Bug 702532
DuplexClientBase Channel Initialization Broken
Last modified: 2011-11-12 19:15:55 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:
I have encountered the same behavior on Debian Wheezy with Mono 2.10.5 from the experimental distribution. Any update on this bug?
(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.
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