I am starting WCF and I am studying at Essential WCF.
I am having a problem using ServiceContract NameSpace and Name. when i run the code i will catch below an InvalidOperationException. But I could not understand clearly.
The binding instance has already been bound to the listening URI 'http: // localhost: 8080 / NamespaceChange01'. If two endpoints want to use the same ListenUri, they must also use the same instance of the binding object. Two conflicting endpoints were either specified in the AddServiceEndpoint () calls, or in the configuration file, or in combination with AddServiceEndpoint () and configuration.
Does anyone know how to avoid an InvalidOperationException?
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ServiceModel; namespace NamespaceChange01 { [ServiceContract(Name = "MyServiceName", Namespace = "http://ServiceNamespace")] public interface IBurgerMaster { [return: MessageParameter(Name = "myOutput")] [OperationContract(Name = "OperationName", Action = "OperationAction", ReplyAction = "ReplyActionName")] double GetStockPrice(string ticker); } [ServiceBehavior(Namespace = "http://MyService")] public class BurgerMaster : IBurgerMaster { public double GetStockPrice(string ticker) { return 100.99; } } class Program { static void Main(string[] args) { ServiceHost host = new ServiceHost(typeof(BurgerMaster)); host.Open(); Console.ReadLine(); host.Close(); } } }
Thanks.
wcf
Shingo tada
source share