Denis
Denis

Reputation: 12077

How to fix the 'Resources' is not a member of 'My'

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

Answers (26)

Erika W
Erika W

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

Nora Moyer
Nora Moyer

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

Reinhard Behrens
Reinhard Behrens

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

Antony Thomas
Antony Thomas

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

NABEEL BIN-HAMDAIN
NABEEL BIN-HAMDAIN

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 :

  1. Solution Explorer - Click Show_All_files
  2. On [ My Project/Resources.resx ] select Resources.resx and press F7
  3. The last Value entry will be all way down of the page
  4. Make sure no duplicate value on that page

Upvotes: 4

Ali
Ali

Reputation: 1

See the below solution and this what I did.

PBImage.Image = Global.ProjectName.My.Resources.Resources.PictureName

Upvotes: 0

Artin Alizadeh
Artin Alizadeh

Reputation: 1

Private lockedImage = My.Resources.Resource.myfile

Hope it works...

Upvotes: 0

Abdul-Hadi Bhat
Abdul-Hadi Bhat

Reputation: 21

I face this problem all the time and this solution works for me all the time.

  1. Click on Show All Files in solution explorer.

  2. Navigate to file named "Resources.resx" under "My Project" folder.

  3. In properties for that file rename the file's [Custom Tool Namespace] to anything other than "My.Resources". (I name it to "My.Resource").

  4. Clean and Rebuild the solution.

  5. Navigate back to "Resources.resx" in properties. Rename the file's [Custom Tool Namespace] back to "My.Resources".

  6. Clean and build the solution again.

Your problem should be fixed.

Upvotes: 2

user2009225
user2009225

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

Diyar
Diyar

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

According to Denis solution: I am adding little more details with his answer.

Step 1 Click on Show All Files button.

enter image description here

Step 2 Click on expand button left to My Project.

enter image description here

Step 3 Right click on Resources.resx.

enter image description here

Step 4 Click on Properties.

enter image description here

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.

enter image description here

Upvotes: 20

ContextCue
ContextCue

Reputation: 323

Ran Into the Same Error

  • Using VS Code 2015
  • Loading in .png image files through the Resource Tab in Project > My Project
  • Making a custom button class with reference to the files in Resource

Solution path

  1. Deleted all the references to the resources in the Resources Tab with [X Remove Resources] and Deleted all the Resources in the file Solution > Project > Resources.
  2. Re-uploaded the .png files through the [add resource] dropdown, loaded files instead of drag and drop.
  3. Renamed file with no underscore (this might be extraneous).
  4. Rebuilt solution

Upvotes: 0

Kuffs
Kuffs

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

Pedro Ramilo
Pedro Ramilo

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:

  • Go to "My Project", select the "Resources" tab
  • On top you'll see "Access Modifier"
  • In my case it was set to "(Custom)". Change it to Friend or "Public" (depending on your needs) and the error should be cleared.

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

BLitande
BLitande

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

Dan
Dan

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

taff kavhu
taff kavhu

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

Cocu_1012
Cocu_1012

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

F&#252;temire
F&#252;temire

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

Darshil Prajapati
Darshil Prajapati

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

AHMAD ALMAHDI
AHMAD ALMAHDI

Reputation: 1

On your new project:

  1. Go to any button using an image
  2. Go to image
  3. Try to load any image
  4. From import - try to load all your images from the other project

So - no errors will appear - I applied this in VS2013

Upvotes: -2

Dan G.
Dan G.

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

Dennis Henry
Dennis Henry

Reputation: 74

In My case the simple fix was

  1. Edit the resources.resx file to not have duplicate entries as mentioned above.
  2. Remove Last Entries you Entered, could be causing the problem
  3. Go to the 'My Project' section for you application.
  4. Change the application type from Windows Forms Application to Class Library, then change it back.
  5. In my case that hooked up the My.Resources again.

Upvotes: 1

Alex
Alex

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

jpmir
jpmir

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

Denis
Denis

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

Related Questions