0

I have a test project that test the Inherit contracts and callback contract.

Update 1 : I updated all of the topic with interfaces implamantations

By reading this article: http://codeidol.com/csharp/wcf/Service-Contracts/Contract-Inheritance/#part-16

This is possibol but when i try it, it fails.

class Program
    {
        static void Main(string[] args)
        {
            ServiceHost Service_IServer = new ServiceHost(new ServiceImplemantation(), new Uri(@"net.tcp://localhost:8080/"));
            Service_IServer.AddServiceEndpoint(typeof(IService), new NetTcpBinding(), "Service");
            Service_IServer.Open();
            ServiceHost Service_I_IP = new ServiceHost(new IPImplemantation(), new Uri(@"net.tcp://localhost:8080/"));
            Service_I_IP.AddServiceEndpoint(typeof(I_IP), new NetTcpBinding(), "Service");
            Service_I_IP.Open();
            Console.ReadLine();
        }
    }
    [ServiceContract]
    public interface I_IP
    {
        [OperationContract]
        string GetIP();
    }
    [ServiceContract]
    public interface IService : I_IP
    {
        [OperationContract]
        void ImTheServer_Print();
    }
    //
    //
    //
    //
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
    public class IPImplemantation : I_IP
    {
        public string GetIP()
        {
            return "1.2.3.4";
        }
    }
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
    public class ServiceImplemantation : IPImplemantation, IService
    {
        public void ImTheServer_Print()
        {
            Console.WriteLine("ImTheServer_Print");
        }
    }

The error:

The ChannelDispatcher at 'net.tcp://localhost:8080/Service' with contract(s) '"I_IP"' is unable to open its IChannelListener.

Stav Alfi
  • 13,139
  • 23
  • 99
  • 171
  • I think you have the answer right in the exception: "interface type is not the target of the ServiceContractAttribute's CallbackContract". GetIP is defined on I_IP, while CallbackContract references IServerCallback. Perhaps inheriting service methods is not supported? just a hunch... – Sergey Apr 19 '13 at 18:02
  • by my google seartch, it is. http://stackoverflow.com/questions/957116/wcf-contract-inherited-contracts – Stav Alfi Apr 19 '13 at 18:03
  • And what about your service / callback implementation? Does it also implements I_IP? – evgenyl Apr 19 '13 at 18:34
  • No,there is implementation to each of the contracts and the service / callback implementation inherit from the I_IP implementation .I wrote my project by this guid : http://codeidol.com/csharp/wcf/Service-Contracts/Contract-Inheritance/#part-16 – Stav Alfi Apr 19 '13 at 18:44
  • The post you pointed on http://stackoverflow.com/users/1413320/sergey you have to have implemented interface. Finaly, your callback should have this method available in amy way – evgenyl Apr 19 '13 at 18:52
  • service / callback implementations inherits the I_IP implementation that have the Get_IP method. – Stav Alfi Apr 19 '13 at 18:55
  • Can you try explicitly implement it? May be when your service/ callback casted to i_ip, it does not work, since they does not "inherited" (implement) the interface? – evgenyl Apr 19 '13 at 18:59
  • I cant becouse I get this exception: The ChannelDispatcher at 'net.tcp://localhost:8080/Service' with contract(s) '"I_IP"' is unable to open its IChannelListener. – Stav Alfi Apr 19 '13 at 19:01
  • Sorry, dont have other input. May be this will help: http://stackoverflow.com/questions/1252791/how-to-solve-the-channeldispatcher-is-unable-to-open-its-ichannellistener-erro – evgenyl Apr 19 '13 at 19:14

1 Answers1

-1

Ensure you decorate it as OneWay.

[OperationContract(IsOneWay = true)]
void GetIP();
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445