Question

Using the command line:

"xsd.exe" "OFX 2.1.1 schema/OFX2_Protocol.xsd" /c /namespace:OFX /nologo"

The resulting C# source file fails to build with these errors:

D:\blah\OFX2_Protocol.cs(19,6): error CS0579: Duplicate 'System.CodeDom.Compiler.GeneratedCodeAttribute' attribute
D:\blah\OFX2_Protocol.cs(20,6): error CS0579: Duplicate 'System.SerializableAttribute' attribute
D:\blah\OFX2_Protocol.cs(21,6): error CS0579: Duplicate 'System.Diagnostics.DebuggerStepThroughAttribute' attribute
D:\blah\OFX2_Protocol.cs(22,6): error CS0579: Duplicate 'System.ComponentModel.DesignerCategoryAttribute' attribute
D:\blah\OFX2_Protocol.cs(23,6): error CS0579: Duplicate 'System.Xml.Serialization.XmlTypeAttribute' attribute
D:\blah\OFX2_Protocol.cs(24,6): error CS0579: Duplicate 'System.Xml.Serialization.XmlRootAttribute' attribute

A similar XSD schema, which I copied from the OFX2 schema then trimmed down to the useful bits that I wanted, generates a C# file which builds just fine, yet has all the same attributes as the full schema's C# representation.

Any idea why? Is the OFX schema broken? Is xsd.exe broken? Is C# broken? Am I broken?

Was it helpful?

Solution

Ok, this answer is a long time coming...

I just ran into the same issue. The problem wasn't in foo.cs, but in foo.designer.cs. You have to remove the duplicate attributes in the second class.

C# should either allow duplicate attributes accross partial classes, or fix xsd to omit attributes in all but the .cs file.

OTHER TIPS

i had the same issue (the same "duplicate attributes" problem) with different schemas. the reason was due to 2 xsd schemas (2 generated files) and in each of them i had the same "type" of element, but with different definitions. renaming of one of the types into different name solved the problem

The latest version of the OFX specification download has an 'OFX3_Protocol_dotNET.xsd' which has been modified from the 'OFX2_Protocol.xsd' to be more suited to .NET code generation tools. I have generated C# from this xsd without any problems although I haven't deserialised any XML yet.

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