Take the 2-minute tour ×

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", "")]
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?

share|improve this question

2 Answers 2

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:


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.

See: http://msdn.microsoft.com/en-us/library/aa347733.aspx

share|improve this answer

Not a direct answer to the question, but the reason why the namespace change isn't working for you is that probably you forgot to update the config contract reference to that service.

In your app/web config, look for the

    <endpoint .. contract="MyServiceName">

Look at the contract attribute. When you didn't specify the namespace in svcutil it generated MyServiceName, and in web.config you referenced your service name with just the name of the interface. Now, your interface is inside a namespace, so you need to change the config to read:

    <endpoint .. contract="MyNamespace.MyServiceName">

In short, the ConfigurationName property in attribute has to match the namespace and class name in the contract attribute of your config file. It's a key by which it finds the matching configuration.

share|improve this answer

Your Answer


