6

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.

dnclem
  • 2,818
  • 15
  • 46
  • 64

3 Answers3

8
  <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.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • I had no idea whitespace could cause this. Anyway, your method seems to have worked, so thanks. – dnclem Dec 06 '11 at 07:08
  • I had a very-VERY huge `` section _(about 5k lines long)_ in all my forms' `.resx` files after visual studio had automatically updated my project like 3 times. Build succeeded after I deleted that section from all files _(I also created a new project and ported everything manually from the old one because VS messed up my project very badly in many ways)_ – Galacticai Mar 04 '21 at 13:41
3

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.

phhkafot
  • 183
  • 1
  • 10
1

In my case, I had downloaded the control from somewhere. All of the source files were in a folder, and the resx file was in the App_LocalResources subfolder. I didn't actually care about anything in the resx file part of it, I think it ws mostly auto-generated blank tags. So I just deleted the resx file. After deleting the resx file, the control compiled successfully.

Eric Barr
  • 3,999
  • 5
  • 29
  • 42