C# resx 文件错误

发布于 2024-12-19 13:07:05 字数 411 浏览 4 评论 0原文

我的 .resx 文件出现奇怪的错误:

“Resx 文件无效。ResX 输入无效。找不到 ResX 读取器和写入器类型名称的有效“resheader”标签。C:\Documents and Settings\Users\My Documents\Visual Studio 2010\Projects\dock\WinForms\Dock\strings.resx"

我所做的是将现有 VS 2010 解决方案中的一些文件替换为一些较旧的文件来自 VS 2008 解决方案的文件,大多数文件工作正常,但我收到此错误,但我不知道如何修复它。如果有什么不同,这里是该文件的源代码。

我正在使用 NET WinForms 4.0,如果这很重要的话。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

无人问我粥可暖 2024-12-26 13:07:05
  <resheader name="resmimetype">
    <value>
      text/microsoft-resx
    </value>
  </resheader>

以某种方式添加了额外的空白。您需要将其删除,使其看起来像这样:

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

您还必须将程序集引用中的版本号从 2.0.0.0 更新为 4.0.0.0。否则,像这样复制 .resx 文件会带来麻烦。当设计者生成的代码尝试使用 .resx 文件中缺失的值时,您将很容易出现 Darn 白屏。

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

苏大泽ㄣ 2024-12-26 13:07:05

好吧,为了解决您的问题,我所做的是将这些行添加到 /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>

我创建了一个新的 VS2010 解决方案,以通常的方式添加了一个新的 .resx 文件,并查看了生成的文件的结构。我发现这些行显然是 VS 需要的,以便正确编译您的文件。

希望我有所帮助:)

编辑:

糟糕,我没有注意到您文件中的现有标签。无论如何,它仍然可以解决您的问题,您只需删除旧标签并保留它们即可。

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.

仅冇旳回忆 2024-12-26 13:07:05

就我而言,我是从某个地方下载了该控件。所有源文件都位于一个文件夹中,resx 文件位于 App_LocalResources 子文件夹中。我实际上并不关心 resx 文件部分中的任何内容,我认为它主要是自动生成的空白标签。所以我只是删除了resx文件。删除resx文件后,控件编译成功。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文