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
URL:
Depends on:
Blocks:
 
Reported: 2013-04-06 04:57 UTC by Jochen Kühner
Modified: 2013-10-14 05:36 UTC (History)
2 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 for Bug 11631 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

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)
        {
            try
            {
                Console.WriteLine("Server is working!");         
                IServiceCallback callback = OperationContext.Current.GetCallbackChannel<IServiceCallback>();
                callback.OnDowork(host);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }

    [ServiceContract(CallbackContract = typeof(IServiceCallback))]
    public interface IMyService
    {
        [OperationContract(IsOneWay=true)] 
        void DoWork(string host);
    }

    [ServiceContract] 
    public interface IServiceCallback
    {
        [OperationContract] 
        void OnDowork(string host);
    }

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

    [CallbackBehavior()]
    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)); 
            host.Open(); 
            Console.WriteLine("Service started ..."); 

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

            proxy.DoWork("Client");			
        }

        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(); 
        }
    }
}