Question

I have two auto-generated classes generated by xsd tool.

The classes have same name and similar member variables.

But many of the members are different.

I am storing these classes in different folders. But there is still a conflict - like this

The type 'Response' already contains a definition for 'Field1'

How do I store these classes to avoid conflict??

I don't want to change anything in the classes as they are auto-generated and changing them might cause XML parsing errors

The classes have structure like below:-

public partial class Response {

public string Field1;

public string Field2;

public string Field3;

}



public partial class Response {

public string Field1;

public string Field2;

public string Field4;

}

The classes are stored as follows

MyProject->Classes->Folder1->Class1

MyProject->Classes->Folder2->Class2

Was it helpful?

Solution

If the entire class is autogenerated by Visual Studio (and not touched/moved afterwards), then the classes have different namespaces as the namespaces are derived from folder names. With different namespaces you shouldn't have conflicts. If XSD tool doesn't work this way, then you need to manually adjust the namespace names or class names.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top