在VS2008中添加到.resx文件中的新字符串导致编译错误,它不存在

发布于 2024-07-27 14:19:15 字数 347 浏览 3 评论 0原文

我最近将我的项目从 VS2005 升级到 VS2008。 我使用 .resx 文件来存储字符串,它在 VS2005 中运行良好。

现在,在 VS2008 中,我向 Strings.resx 文件添加了一个新字符串,并在我的代码 (C#) 中使用了它。 但我收到一个编译错误,表明我的新字符串不存在于 Strings 中。 我让我的同事在他的机器上检查一下,他也遇到了同样的问题。 我发现 VS2008 将新字符串添加到 .resx 文件中,但没有添加到 .Designer.cs 文件中。

这是一个已知问题吗? 有什么办法可以解决吗? (除了手动将代码添加到.Designer.cs)

提前致谢。

I recently upgraded my projects from VS2005 to VS2008. I use a .resx file to store strings and it worked fine with VS2005.

Now, with VS2008, I added a new string to Strings.resx file and used it in my code (C#). But I got a compilation error that my new string doesn't exist in Strings.
I asked my colleague to check it on his machine and he got the same problem.
I found out that VS2008 add the new string to the .resx file but not to the .Designer.cs file.

Is it a known issue? Is there any way to fix it? (besides adding the code manually to .Designer.cs)

Thanks in advance.

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

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

发布评论

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

评论(2

葬シ愛 2024-08-03 14:19:15

事实证明,问题的发生是因为我从 StarTeam 签出后,我的 .resx 和 .Designer.cs 文件是只读的。

在 VS2005 中,有人问我是否要使两个文件都可写,当我回答“是”时,.Designer.cs 文件也被修改,因此我可以从代码中访问新成员。 但在VS2008中,它不会询问我是否要使.Designer.cs文件可写,因此它保持只读状态,VS无法修改它,因此我无法访问新成员。

总结一下:
在更改 .resx 文件以使其在 VS2008 中正常工作之前,应始终使 .resx 文件和 .Designer.cs 文件都可写。

Turns out that the problem occurred because my .resx and .Designer.cs files was read-only after I checked them out from StarTeam.

In VS2005 I was asked if I want to make both files writable and when I answered yes the .Designer.cs file was also modified, so I could access the new member from my code. But in VS2008, it doesn't ask if I want to make the .Designer.cs file writable, so it stays read-only and VS can't modify it, so I can't access the new member.

To summarize:
You should always make both .resx file and .Designer.cs file writable before changing the .resx file to make it work correctly with VS2008.

女中豪杰 2024-08-03 14:19:15

我刚刚尝试在 VS2005 中使用 .resx 文件创建一个项目,然后将其转换为 VS2008,没有任何问题。 不过我想我以前见过这个:在VS2008的解决方案资源管理器中,.resx和.designer文件是分开显示的吗? 即 .resx 文件旁边没有“+”图标,该图标将展开以显示 .designer 文件。

如果是这种情况,我确信有某种方法可以让 VS2008 再次将它们视为连接的文件。 也许在解决方案资源管理器中突出显示两者,右键单击并查看选项是什么?

I've just tried creating a project in VS2005 with a .resx file and then converting it to VS2008, and there are no problems. However I think I have seen this before: in the Solution Explorer in VS2008, are the .resx and the .designer files displayed separately? i.e. there isn't a '+' icon next to the .resx file which will expand to show the .designer file.

If this is the case, I'm sure there's some way of getting VS2008 to treat them as connected files again. Maybe highlight both in Solution Explorer, right-click and see what the options are?

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