Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# resx file error

I'm getting a weird error with my .resx files:

"Invalid Resx file. ResX input is not valid. Cannot find valid "resheader" tags for the ResX reader and writer type names. C:\Documents and Settings\Users\My Documents\Visual Studio 2010\Projects\dock\WinForms\Dock\strings.resx"

What I did was replace some files in an existing VS 2010 solution with some older ones from VS 2008 solution, most of the files work fine but I get this error and I don't know how to fix it. If it makes a difference, here is the source code of that file.

I'm using NET WinForms 4.0, if that matters.

like image 563
rayanisran Avatar asked Dec 05 '11 19:12

rayanisran


2 Answers

  <resheader name="resmimetype">
    <value>
      text/microsoft-resx
    </value>
  </resheader>

Extra white space got added somehow. You'll need to remove it so it looks like this:

  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>

You also must update the version numbers in the assembly references from 2.0.0.0 to 4.0.0.0. Copying .resx files like this is otherwise a good way to get into trouble. You'll easily get the White Screen of Darn when the designer generated code tries to use a missing value in the .resx file.

like image 142
Hans Passant Avatar answered Sep 22 '22 09:09

Hans Passant


Alright so what I did in order to solve your problem was add these lines to your file just before /root:

  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="version">
    <value>1.3</value>
  </resheader>
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>

I created a new VS2010 solution, added a new .resx file the usual way and looked at the structure of the generated file. I found these lines which, apparently, VS needs in order to compile your file appropriately.

Hope I helped :)

EDIT:

Oops my bad, I didn't notice the existing tags in your file. Anyway, it still solves your problem and you can just delete the old tags and keep these instead.

like image 22
phhkafot Avatar answered Sep 18 '22 09:09

phhkafot