none
Could not be found in the list of contracts

    Question

  • Hi,

    I'm struggling with my first WCF duplex service and all of a sudden I have an error that I didn't have before I renamed some namespaces.

    Now I get the error : "The contract name MarketDataLibrary.IMarketDataServer could not be found in the list of contracts implemented by the service MarketDataHost.MarketDataHub"

    It happens on the AddServiceEndpoint line:

    Code Snippet

    marketData = new MarketDataHub();                              
    host = new ServiceHost(marketData);
    host.AddServiceEndpoint(typeof(IMarketDataServer), tcpBinding, urlService);



    (this is done in the form of the host in the MarketDataHost namespace)

    And the IMarketDataServer is implemented like so:

    Code Snippet

    namespace MarketDataLibrary
        [ServiceContract(
            SessionMode = SessionMode.Required,
            CallbackContract = typeof(IMarketDataCallback))]
        public interface IMarketDataServer
        {
            [OperationContract(IsOneWay = false, IsInitiating = true)]
            string Subscribe();
            [OperationContract(IsOneWay = false, IsTerminating = true)]
            void Unsubscribe();
        }



    The MarketDataHub class:

    Code Snippet

        public class MarketDataHub
        {
            public MarketDataHub()
            {
                Hub = new MarketDataFIXClass();
            }

            private MarketDataFIXClass hub;
            public MarketDataFIXClass Hub
            {
                get { return hub; }
                set { hub = value; }
            }
            private IMarketDataCallback _callback;
            public IMarketDataCallback Callback
            {
                get { return _callback; }
                set { _callback = value; }
            }  
            public void DisconnectAll()
            {
                for (int i = 0; i < Hub.CounterParties.VendorList.Count; i++)
                {
                    Hub.CounterParties.VendorList[i].VendorConnection.Logout();
                    Hub.CounterParties.VendorList[i].VendorConnection.Dispose();
                }

            }
        }



    I've tried adding the IMarketDataServer contract to this class as well but that gives me the same error.

    Thanks,
      nisbus

    Wednesday, March 19, 2008 1:48 PM

Answers

  • MarketDataHost.MarketDataHub doesnt implement the MarketDataLibrary.IMarketDataServer interface.

    In your code here:

    marketData = new MarketDataHub();                              
    host = new ServiceHost(marketData);
    host.AddServiceEndpoint(typeof(IMarketDataServer), tcpBinding, urlService);

    The
    marketData is the server and it must implement the interface you are trying to assign the endpoint to. So derive from taht interface in MarketDataHub and implement those methdods and all will be good.
    Wednesday, March 19, 2008 2:08 PM

All replies

  • MarketDataHost.MarketDataHub doesnt implement the MarketDataLibrary.IMarketDataServer interface.

    In your code here:

    marketData = new MarketDataHub();                              
    host = new ServiceHost(marketData);
    host.AddServiceEndpoint(typeof(IMarketDataServer), tcpBinding, urlService);

    The
    marketData is the server and it must implement the interface you are trying to assign the endpoint to. So derive from taht interface in MarketDataHub and implement those methdods and all will be good.
    Wednesday, March 19, 2008 2:08 PM
  • Thank you Dan, I should have been using
    marketData = new MarketDataServer; instead of new MarketDataHub()
    It works now Smile

    nisbus
    Wednesday, March 19, 2008 2:49 PM
  • Hello All,

    Below link provide a good explanation of one of the scenario for this error and solution for the same


     
    • Proposed as answer by Fighter.cs3 Saturday, June 12, 2010 11:19 PM
    Saturday, June 12, 2010 11:19 PM