更改资源文件(resx)命名空间和访问修饰符 [英] Changing Resource files (resx) namespace and access modifier

查看:329
本文介绍了更改资源文件(resx)命名空间和访问修饰符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Web项目中,我正在App_GlobalResources文件夹中使用4个资源文件.在我进入项目之前,已经创建了其中一个(lang.resx).它具有正确的名称空间(WebApplication.App_GlobalResources)和访问修饰符:public.

另一方面,我刚刚创建的其他三个资源文件具有不同的命名空间(Resources)和internal访问修饰符,由于它是禁用的.如果我尝试直接在designer.cs文件中进行更改,则该修改将在文件的下一次保存时被取消.

这不是一个严重的错误,但可能会误导该项目中的其他开发人员为他们将使用的资源文件找到不同的名称空间和访问修饰符.

解决方案

我尚不确定问题出在哪里,但我可以告诉您可以通过更改用于生成代码的工具来解决. /p>

当我尝试关注本文时,我也偶然发现了这个问题.按照作者的建议下载源文件后,我注意到已经存在的资源文件在自定义工具"属性中具有以下类:"PublicResXFileCodeGenerator".另外,构建操作"属性设置为嵌入式资源",但是我不确定这是否是问题的一部分.

我创建的任何新资源文件都使用了自定义工具"GlobalResourceProxyGenerator".用实际的问题"PublicResXFileCodeGenerator"覆盖后,似乎可以解决问题.

我还注意到当前资源文件的格式为"2.0",而新文件的格式为"1.3".使用XML编辑器(或使用Visual Studio本身的打开方式")打开resx文件时,您会看到此信息.

我希望您可以像这样使它工作,但这并不理想.可能是Visual Studio 2008和SP1或类似的安装问题.

更新:

此博客条目可能也有帮助. /p>

In my webproject I'm using 4 resources files in my App_GlobalResources folder. One of them (lang.resx) has been created before my arrival on the project. It has the correct namespace (WebApplication.App_GlobalResources) and access modifier : public.

On the other hand, the three others Resource files that I just created have a different namespace (Resources) and internal access modifier, and I can't change it on the Resource File Form from Visual Studio because it's disabled. If I try to change it directly in the designer.cs file, the modifications are cancelled on the next save of the file.

It's not a critical bug but it can be misleading for the others developers on the project to find different namespaces and access modifiers for the resources files they will use.

解决方案

I'm not entirely sure where the problem lies yet, but I can tell you that you can solve it by changing the tool used to generate the code.

When I tried to follow this article, I also stumbled onto this problem. After downloading the source files as the author suggested, I noticed that the resource file that were already present had the following class in the "Custom Tool" property: "PublicResXFileCodeGenerator". Also, the "Build Action" property was set to "Embedded Resource", but I'm not sure if that's part of the problem.

Any new resource file that I created used the custom tool "GlobalResourceProxyGenerator". After overwriting this with the aforementioned "PublicResXFileCodeGenerator" seemed to solve the problem, whatever the real problem may be.

I also noticed that the present resource file was in the "2.0" format, whereas new files were in the "1.3" format. You can see this when you open the resx file using an XML editor (or by using "open with" from visual studio itself).

I hope you can make it work like this, it's not ideal though. It's likely to be an installation issue with Visual Studio 2008 and SP1, or something like that.

Update:

This blog entry may also help.

这篇关于更改资源文件(resx)命名空间和访问修饰符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆