In .NET 4.5, my WCF creation using svcutil suddenly seems broken (I only use .NET 4.0 until recently) ....
With the default settings that I use to convert a pre-existing WSDL to my C # WCF proxy class:
c:> svcutil.exe /n:*,MyNamespace /out:WebService MyService.wsdl
I create this C # file:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] [System.ServiceModel.ServiceContractAttribute(ConfigurationName="MyService.IMyService1")] public interface IMyService1 { [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IMyService1/IsAlive", ReplyAction="http://tempuri.org/IMyService1/IsAliveResponse")] [System.ServiceModel.FaultContractAttribute(typeof(MyService.MyFault), Action="http://tempuri.org/IMyService1/IsAliveErrorInfoFault", Name="MyServiceErrorInfo", Namespace="http://schemas.datacontract.org/2004/07/MyService.Types")] string IsAlive(); [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IMyService1/IsAlive", ReplyAction="http://tempuri.org/IMyService1/IsAliveResponse")] System.Threading.Tasks.Task<string> IsAliveAsync();
This will not work - if I try to instantiate the implementation of this interface in ServiceHost
using (ServiceHost svcHost = new ServiceHost(typeof(MyService01Impl))) { svcHost.Open(); Console.WriteLine("Host running ..."); Console.ReadLine(); svcHost.Close(); }
I get this error:
There cannot be two operations in the same contract with the same name, the IsAlive and IsAliveAsync methods of type "MyService01Impl" violate this rule. You can change the name of one of the operations by changing the method name or by using the Name property of OperationContractAttribute.
Why svcutil unexpectedly generate code that doesn't work?
If I use the /async with svcutil , then I get an โold styleโ asynchronous template with BeginIsAlive and EndIsAlive and everything works again, but how can I tell WCF / svcutil generate things without async at all?
source share