Bug 11631 - Exception with Duplex Channel, Mono tries to cast to a not implemented Interface
Summary: Exception with Duplex Channel, Mono tries to cast to a not implemented Interface
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: WCF assemblies (show other bugs)
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2013-04-06 04:57 UTC by Jochen Kühner
Modified: 2013-10-14 05:36 UTC (History)
2 users (show)

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


Description Jochen Kühner 2013-04-06 04:57:53 UTC
I have a project wich is running verry well on NET 4.0.

On Mono I got the following Exception:

Exception Object of type 'System.ServiceModel.MonoInternal.DuplexServiceRuntimeChannel' doesn't match target type 'System.ServiceModel.IClientChannel' at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00078] in /mcc/mono/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:243 at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /mcc/mono/mono/mcs/class/corlib/System.Reflection/MethodBase.cs:114 at System.ServiceModel.ClientRealProxy.DoInvoke (IMessage inputMessage) [0x0003a] in /mcc/mono/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRealProxy.cs:100 at System.ServiceModel.ClientRealProxy.Invoke (IMessage inputMessage) [0x00000] in /mcc/mono/mono/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 /mcc/mono/mono/mcs/class/corlib/System.Runtime.Remoting.Proxies/RealProxy.cs:193

I looked in the Source and think it's correct that the Exceptin Occures (IClientChannel is not implement on DuplexServiceRuntimeChannel)

Do you need more Info? some Parts of my code?

Parts of my Proxy creation:

bind = new NetTcpBinding();
EndpointAddress myEndpoint = new EndpointAddress(address);
var akFactory = (new DuplexChannelFactory<T>(new InstanceContext(callbackObject), bind));
proxy = akFactory.CreateChannel(myEndpoint);
Comment 1 David Lambert 2013-10-14 04:39:55 UTC
I have the same issue using Mono 3.2.3 on OSX.
Comment 2 David Lambert 2013-10-14 05:36:29 UTC
using System;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.ServiceModel.Channels;

namespace Test
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, IncludeExceptionDetailInFaults = true)]
    public class MyService : IMyService
        public void DoWork(string host)
                Console.WriteLine("Server is working!");         
                IServiceCallback callback = OperationContext.Current.GetCallbackChannel<IServiceCallback>();
            catch (Exception ex)

    [ServiceContract(CallbackContract = typeof(IServiceCallback))]
    public interface IMyService
        void DoWork(string host);

    public interface IServiceCallback
        void OnDowork(string host);

    public class ServiceCallback : IServiceCallback
        public void OnDowork(string host)
            Console.WriteLine(host + " got called back!");

    class MainClass
        const int Port = 60500;

        public static void Main(string[] args)
            var host = new ServiceHost(typeof(MyService)); 
            var binding = new NetTcpBinding(); 
            binding.Security.Mode = SecurityMode.None; 
            host.AddServiceEndpoint(typeof(IMyService), binding, string.Format("net.tcp://localhost:{0}", Port)); 
            Console.WriteLine("Service started ..."); 

            var callback = new ServiceCallback();
            var proxy = GetClientProxy(callback);


        private static IMyService GetClientProxy(IServiceCallback callback)
            var factory = new DuplexChannelFactory<IMyService>(callback, new NetTcpBinding(SecurityMode.None), string.Format("net.tcp://localhost:{0}", Port)); 
            return factory.CreateChannel(); 

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