Article ID: 2268, created on Oct 18, 2007, last review on May 8, 2014

  • Applies to:
  • Virtuozzo for Windows 3.5.1 SP1


C# compiler produces the following error during Visual Studio Project compilation:

error CS0542: 'set_xxx': member names cannot be the same as their enclosing type


Microsoft Visual C# .NET may produce errors when generating the client code from WSDL similar to the following example:

<xs:element name="set_xxx">
      <xs:element name="xxx" type="XXXtype" />

Note that the function set_xxx has a parameter xxx. Microsoft Visual C# .NET will generate the following code:

public partial class set_xxx {
    private string xxxField;
    /// <remarks/>
    public string xxx {
        get {
            return this.xxxField;
        set {
            this.xxxField = value;

As you can see, the function has the same name as the class name. This causes the C# compiler to produce the error above.


Note: The case is not Virtuozzo related issue, please contact Microsoft support if the solution below does not help to solve it.

Create a batch file wsdlc.bat, for example, containing the following code and save it in your project directory:


set WS=%1Web References\%3

copy "%WS%\" "%WS%\Reference.discomap"

"%VS80COMNTOOLS%\..\..\SDK\v2.0\Bin\wsdl.exe" /l:CS /fields /out:"%WS%\Reference.cs" /n:%2.%3 "%WS%\Reference.discomap"

del "%WS%\Reference.discomap"


exit /b 0

Main part of this script is a calling of wsdl.exe - WSDL compiler - with option /fields. It force compiler don't generate properties and use fields:

public partial class set_xxx {
    private string xxx;

Please note that path to wsdl.exe can be different depending on system.

The file generates the new Reference.cs file (the file containing the proxy classes) fixing the problem described above by generating the regular properties instead of C#-style get/set fields. Do not try to run the file. It will by run automatically after we complete the rest of the steps.

In the Microsoft Visual C# .NET development environment, select Project > Properties menu item. Select Build Events option in the left pane. Now in the right pane, modify the parameter Pre-build Event Command Line to contain the following line:

$(ProjectDir)wsdlc.bat $(ProjectDir) $(ProjectName) VZA

Where VZA - is a namespace for generated classes.

Note: Make sure that the Reference.cs file is not currently opened in the IDE, otherwise the compiler will use it instead of the new file that will be generated by our batch file.

Select the Build > Build Solution menu option to build your solution. This will take longer than usual because the wsdlc.bat file that we created will re-generate the proxy classes.

After the build is completed, the Reference.cs file will contain the newly generated stubs. At this point you can remove or comment out the entry that used in the Project > Properties > Pre-build Event Command Line option. If you do not, the stubs will be re-generated every time you build your solution.

If you decide to update the client code from WSDL located on our Web server again, make sure that you repeat the steps described here again.


The request describing this defect was submitted to Microsoft: #FDBK46565

1348db476c8a5844ffbef8d503db9c15 965b49118115a610e93635d21c5694a8 d02f9caf3e11b191a38179103495106f 2897d76d56d2010f4e3a28f864d69223

Email subscription for changes to this article
Save as PDF