I'm using SvcUtil.exe to generate my WCF code, like this:
SvcUtil.exe http://www.MyServer.com:8080/MyService/mex /out:"C:\test.cs" /mc
I can get it to work, but if I set add a /namespace
argument(/namespace:*,MyNamespace
), it overwrites the ConfigurationName
value on the generated ServiceContractAttribute
of the generated interface:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="MyNamespace.MyServiceName")]
public interface MyServiceName
{ ... }
If I don't set the namespace, the value of ConfigurationName
is "MyServiceName", which is correct ("MyNamespace.MyServiceName" is incorrect and does not work). I've tried adding a /ServiceName:MyService argument, but it tells me that it says
Error: The /serviceName: option conflicts with other options. Review your use of the tool.
How can I specify a namespace for my generated classes without overwriting the ConfigurationName?
I'm having the same issue. I have a ServiceReference that has ConfigurationName="MyWebService.MyWebServiceSoap" that was generated when it was added through VisualStudio.NET 2010. When I use svcutil to generate that same class from msbuild, svcutil wants to set the ConfigurationName equal to the value I set for the namespace. So if I set the /n attribute like so:
/n:*,MyApplication.MyWebService.MyWebServiceSoap
I get the proper namespace for my generated classes, but the ConfigurationName is also set to MyApplication.MyWebService.MyWebServiceSoap.
This seems to indicate that VS.NET does not use svcutil, and there are posts I found that seem to indicate this as well.
I wish I had a better answer, but since I'm using svcutil from MSBuild, my solution was to let svcutil generate the class with the incorrect ConfigurationName and then use the FileUpdate task to modify that name using a regex. Again, it's far from ideal, but I can't see anything in the svcutil documentation that lets you specify the ConfigurationName.
Also, it's worth mentioning that the serviceName option is used to export metadata from compiled code, it's not valid for generating client proxy classes, which is probably why you were getting that serviceName option conflicts error.