.net 如何修复“资源”不是“我的”的成员
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9299768/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to fix the 'Resources' is not a member of 'My'
提问by Denis
I am using VS2010 and in all of my projects "My.Resources" is available and shows all the files that are in the "resources" section of the project. In this one project I have a bunch of resource files in the project but the compiler complains:
我正在使用 VS2010,并且在我的所有项目中,“My.Resources”都可用并显示项目“资源”部分中的所有文件。在这个项目中,我在项目中有一堆资源文件,但编译器抱怨:
'Resources' is not a member of 'My'
Where I do:
我在哪里做:
Private lockedImage = My.Resources.myfile
How do I fix this?
我该如何解决?
回答by Denis
In VS2010 Look in the Solution Explorer at [Your Project] -> My Project -> Resources.resx. Click on "Properties" and make sure that "Custom Tool Namespace" says "My.Resources". (took me an hour to figure this out)
在 VS2010 中,在 [Your Project] -> My Project -> Resources.resx 处查看解决方案资源管理器。单击“属性”并确保“自定义工具命名空间”显示为“My.Resources”。(我花了一个小时才弄明白这个)
回答by Fütemire
The above is a valid solution but I noticed in my case that the error resulted from another issue. Sometimes what we think is the error is actually the result of a preceding error. You can get this error as well if you deleted the resources from the Resourcefolder in the Solution Explorer. If you intended on removing these resources then you need to actually delete them by clicking the "Remove Resource" button in the Resources section of your project properties. This will then remove traces of the missing item in the underlying auto-generated code. After clearing an icon resource file that was deleted improperly I no longer had an issue with VS losing reference to My.Resources.
以上是一个有效的解决方案,但我注意到在我的情况下,错误是由另一个问题引起的。有时我们认为的错误实际上是先前错误的结果。如果您从解决方案资源管理器的Resource文件夹中删除了资源,您也会收到此错误。如果您打算删除这些资源,那么您需要通过单击项目属性的“资源”部分中的“删除资源”按钮来实际删除它们。然后,这将删除底层自动生成代码中丢失项目的痕迹。清除了一个被不正确删除的图标资源文件后,我不再遇到 VS 丢失对 My.Resources 的引用的问题。
Hope that helps someone.
希望能帮助某人。
Update: I also received this error when I added a resource file to my project when it was open in another program. In my case I added a User Manual word document but it was still open in Word. All I had to do to remedy this issue was delete the word document out of my resources, close it in Word and re-add it again. Once I built the solution the errors went away.
更新:当我在另一个程序中打开一个资源文件到我的项目时,我也收到了这个错误。就我而言,我添加了一个用户手册 word 文档,但它仍然在 Word 中打开。为了解决这个问题,我所要做的就是从我的资源中删除 Word 文档,在 Word 中关闭它并重新添加它。一旦我构建了解决方案,错误就消失了。
回答by jpmir
I had the same error while creating a new solution based on elements (forms, classes, resources, etc.) from another project with different name.
我在基于另一个项目中具有不同名称的元素(表单、类、资源等)创建新解决方案时遇到了同样的错误。
Since my resources namespace was "My.Resources" as @denis pointed out previously, I tried to regenerate resources namespace by doing right click over "Resources.resx" in solution explorer and click on "Run custom tool"... That displayed a window that shows a message saying that some icons declared in XML were not present in the system.
由于我的资源命名空间是@denis 之前指出的“My.Resources”,我尝试通过在解决方案资源管理器中右键单击“Resources.resx”并单击“运行自定义工具”来重新生成资源命名空间...显示一条消息的窗口,指出某些在 XML 中声明的图标在系统中不存在。
Since I did a search and replace on the entire solution looking for the old name and changing to the new one, that affected the XML file where resources are declared. Changing the icon file name did the trick.
由于我对整个解决方案进行了搜索和替换,寻找旧名称并更改为新名称,这影响了声明资源的 XML 文件。更改图标文件名可以解决问题。
回答by Mohammad Zulfikar
According to Denis solution: I am adding little more details with his answer.
根据丹尼斯的解决方案:我在他的回答中添加了更多细节。
Step 1Click on Show All Filesbutton.
步骤 1单击“显示所有文件”按钮。
Step 2Click on expand button left to My Project.
步骤 2单击“我的项目”左侧的展开按钮。
Step 3Right click on Resources.resx.
步骤 3右键单击Resources.resx。
Step 4Click on Properties.
步骤 4单击“属性”。
Step 5- Change the name My.Resourcesto anything example My.ResourcesRepairthen save changes and again name it back to My.Resourcesand save changes and then rebuild.
第 5 步-将名称My.Resources更改为任何示例My.ResourcesRepair然后保存更改并再次将其命名回My.Resources并保存更改然后重建。
回答by Alex
The previous solutions here did not work for me.
这里以前的解决方案对我不起作用。
The 'Resources' is not a member of 'My'was caused by trying to add an icon to a button. I tried running the custom tool on the Resources.resxand kept getting an error.
这'Resources' is not a member of 'My'是由于尝试向按钮添加图标引起的。我尝试在 上运行自定义工具Resources.resx并不断收到错误消息。
My solution was to go into My Project > Resources and remove the added icon. Once that was done I did a clean & rebuild. That did the trick for me.
我的解决方案是进入“我的项目”>“资源”并删除添加的图标。完成后,我进行了清理和重建。这对我有用。
回答by Dennys Henry
In My case the simple fix was
在我的情况下,简单的修复是
- Edit the
resources.resxfile to not have duplicate entries as mentioned above. - Remove Last Entries you Entered, could be causing the problem
- Go to the 'My Project' section for you application.
- Change the application type from
Windows Forms ApplicationtoClass Library, then change it back. - In my case that hooked up the
My.Resourcesagain.
resources.resx如上所述,编辑文件以消除重复条目。- 删除您输入的最后一个条目,可能是导致问题的原因
- 转到您的应用程序的“我的项目”部分。
- 将应用程序类型从 更改
Windows Forms Application为Class Library,然后再更改回来。 - 在我的情况下,
My.Resources再次连接。
回答by Dan G.
Fütemire described my problem. I had just "cleaned up" some unused files in both the resources (doing an Open My Project within VS) and probably (I must admit), I deleted some files directly from the Resources folder outside of VS. Oops.
Fütemire 描述了我的问题。我刚刚“清理”了资源中的一些未使用的文件(在 VS 中打开我的项目),并且可能(我必须承认),我直接从 VS 外部的 Resources 文件夹中删除了一些文件。哎呀。
I just opened Resources.resx file and found two items that red underscores, indicating it couldn't find these files. I removed those data blocks within the XML file and that fixed the problem for me. Thanks.
我刚刚打开Resources.resx文件,发现有两个红色下划线的项目,表示找不到这些文件。我删除了 XML 文件中的那些数据块,这为我解决了问题。谢谢。
回答by Darshil Prajapati
In vb.net , if Resouce File available than just check Resorces.resx is available And Resorces.Designer.vb not Available than once Exclude Resorces.resx and include Resorces.resx than automatically generate Resorces.Designer.vb you got to fix all error related..
在 vb.net 中,如果 Resouce 文件可用而不仅仅是检查 Resorces.resx 可用并且 Resorces.Designer.vb 不可用超过一次 排除 Resorces.resx 并包含 Resorces.resx 比自动生成 Resorces.Designer.vb 你必须修复所有错误有关的..
回答by taff kavhu
I found an unusual way to fix this error. After trying so many things.
我找到了一种解决此错误的不寻常方法。在尝试了很多东西之后。
I deleted images from the resources folder and ended up with 'Resources' is not a member of 'My' 170 errors
我从资源文件夹中删除了图像,结果是“资源”不是“我的”170 错误的成员
This fixed the error. I deleted all files in the resource folder. I restored them from the recycle bin and all the errors went.
这修复了错误。我删除了资源文件夹中的所有文件。我从回收站中恢复了它们,所有错误都消失了。
回答by Dan
simply edit the Resources.resxin notepad++. Trace the cause of the error (error displays in the Resources tab of your project properties), remove the line that causes the error. then on your solution explorer, right-click Resources.resxthen Run Custom Tool.
只需Resources.resx在记事本++中编辑。跟踪错误原因(错误显示在项目属性的资源选项卡中),删除导致错误的行。然后在您的解决方案资源管理器上,右键单击Resources.resxthen Run Custom Tool。
this would surely resolve the problem.
这肯定会解决问题。


