Reputation: 12077
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:
'Resources' is not a member of 'My'
Where I do:
Private lockedImage = My.Resources.myfile
How do I fix this?
Upvotes: 16
Views: 79162
Reputation: 11
I had this issue. It was because I added a table to my entity framework name "Resources". I removed the table and then my report loaded correctly. I just needed to rename my "Resources" table so there would be no conflict.
Upvotes: 1
Reputation: 1
My solution was to clear everything out of the resources using Project > Properties > Resources. Then save. Then add items back one at a time. The problem was caused when I tried to highlight many files and a folder and tried to import everything into my resources all at once. That's when everything broke. Once I reset my resources, everything was fine. All the red underlines went away.
Upvotes: 0
Reputation: 768
This is a bit of a late answer, but I found that the reference to the Project Namespace is actually resolved by reading the Resources.Designer.cs file. Once this is created and available under the Project->Properties section the Namespace should be resolved.
How the system resolves the namespace to get to the Resources section
Upvotes: 0
Reputation: 1
The issue is usually happened because more than one Resource file or folder exits in your project with the same.
This may be in some other directories .
Please Rename them with other appropriate names.
Keep the only one that you use with the name "Resourses"
Upvotes: 0
Reputation: 51
On my case I just went to the code of Resources.rex and I deleted the last value entry of the image that caused the problem .. save then reopen again .. It worked fine to me.
<data name="imagename" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\imagename.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
... HOW to show the Resorces.rex code :
Upvotes: 4
Reputation: 1
See the below solution and this what I did.
PBImage.Image = Global.ProjectName.My.Resources.Resources.PictureName
Upvotes: 0
Reputation: 1
Private lockedImage = My.Resources.Resource.myfile
Hope it works...
Upvotes: 0
Reputation: 21
I face this problem all the time and this solution works for me all the time.
Click on Show All Files in solution explorer.
Navigate to file named "Resources.resx" under "My Project" folder.
In properties for that file rename the file's [Custom Tool Namespace] to anything other than "My.Resources". (I name it to "My.Resource").
Clean and Rebuild the solution.
Navigate back to "Resources.resx" in properties. Rename the file's [Custom Tool Namespace] back to "My.Resources".
Clean and build the solution again.
Your problem should be fixed.
Upvotes: 2
Reputation: 11
In VS2013, 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".
If it does not work just try putting there "My." - Just this "My."
Upvotes: 0
Reputation: 11
Just remove last file you entered , and build program again "if you need to put that file again , change file location then enter again"
Upvotes: 1
Reputation: 984
According to Denis solution: I am adding little more details with his answer.
Step 1 Click on Show All Files button.
Step 2 Click on expand button left to My Project.
Step 3 Right click on Resources.resx.
Step 4 Click on Properties.
Step 5 - Change the name My.Resources to anything example My.ResourcesRepair then save changes and again name it back to My.Resources and save changes and then rebuild.
Upvotes: 20
Reputation: 323
Ran Into the Same Error
Solution path
Upvotes: 0
Reputation: 35661
I'm unsure if Web Applications work differently or not with regards to the My.Resources
namespace but none of the other solutions in this question helped at all.
My resources were auto completing normally but I got the
Resources is not a member of My
errors in the error window.
I finally resolved the issue by importing the My namespace at the top of the class file.
i.e
Imports <MyAppNameSpace>.My
and could then access the resources by calling only:
String x = Resources.<NameOfMyResource>
Strangely it would not work importing ONLY the App namespace. I had to also import My
too
Upvotes: 1
Reputation: 189
After facing the same issue having used a couple of tools to assist in Resource Translation, this is what fixed it for me:
I'm using ResX Resource Manager plug in to assist with the translation. This error seems to keep re appearing whenever I try to manage a resource in Resource Manager while having "My Project" window open. When this happens, ResX Resource Manager throws an error and the My.Resources error re appears. Repeating the procedure above restores things to working condition again.
Upvotes: 0
Reputation: 316
Had more luck changing "My.Resources
" to "MyResources
"
and changing the Access Modifier of "Resources.resx
" to Public (it was previusly Friend Access Modifier)
Fixed the error for me
Upvotes: 1
Reputation: 11
simply edit the Resources.resx
in 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.resx
then Run Custom Tool
.
this would surely resolve the problem.
Upvotes: 1
Reputation: 11
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
This fixed the error. I deleted all files in the resource folder. I restored them from the recycle bin and all the errors went.
Upvotes: 1
Reputation: 119
How I fixed this: Visual studio points the error to this line: Global.Resources.rptRecal.ResourceManager
It says can not find rptRecal. I know this file exists, so I just removed the line, type it again, let the "auto complete" feature kick in.
Upvotes: 0
Reputation: 1893
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 Resource folder 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.
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.
Upvotes: 15
Reputation: 97
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..
Upvotes: 1
Reputation: 1
On your new project:
So - no errors will appear - I applied this in VS2013
Upvotes: -2
Reputation: 599
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.
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.
Upvotes: 1
Reputation: 74
In My case the simple fix was
resources.resx
file to not have duplicate entries as mentioned above.Windows Forms Application
to Class Library
, then change it back.My.Resources
again.Upvotes: 1
Reputation: 4938
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.resx
and kept getting an error.
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.
Upvotes: 3
Reputation: 101
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.
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.
Upvotes: 5
Reputation: 12077
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)
Upvotes: 19