chris579 chris579 - 2 months ago 23
C# Question

WPF: Invalid Resx file. ResX input is not valid

I got a WPF project which ran fine but after some time I got the really awkward compiler error


Invalid Resx file. ResX input is not valid. Cannot find valid "resheader" tags for the ResX reader and writer type names.


I didn't changed anything to my resx file. I don't even have resources defined.

My Resources.resx file:

<?xml version="1.0" encoding="utf-8"?>
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element Header="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element Header="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element Header="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute Header="Header" type="xsd:string" />
<xsd:attribute Header="type" type="xsd:string" />
<xsd:attribute Header="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element Header="assembly">
<xsd:complexType>
<xsd:attribute Header="alias" type="xsd:string" />
<xsd:attribute Header="Header" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element Header="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element Header="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element Header="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute Header="Header" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute Header="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute Header="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element Header="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element Header="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute Header="Header" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader Header="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader Header="version">
<value>2.0</value>
</resheader>
<resheader Header="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader Header="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>


I already had a look at some answers in SO but my value tag for reader and writer seems to be valid (not seperated by new lines etc.)

Answer

Replace all your Header attributes with name e.g.:

<xsd:element name="root" msdata:IsDataSet="true"></xsd:element>

You've probably changed it by accident if you've used "Replace all" somewhere.
Or you could just delete the file if you're not using it.

Additionally, you can always use online tools such as this to check if your xml and schema are valid.