2

As soon as I added a resource to my project, all code references containing "Properties.Resources" were marked as an error, telling me that "The type or namespace name 'Resources' does not exist in the namespace 'MyProject.Properties' (CS0234).

The only thing I did was navigating to the properties of my project and then adding a resource in the resource tab by clicking "Add resource" and then selecting an exisitng PNG file. When the resource file was added, the errors suddenly appeared.

Normally, these errors didn't occur as I already added a lot of other resources to my project. Why do these errors suddenly appear?

It's a WinForms application and the target Framework is .NET Framework 4.6.1.

Pete Hilde
  • 659
  • 1
  • 10
  • 24

4 Answers4

5

I solved the problem on my own.

Some time ago I changed the name of my project's default namespace by only renaming it. However, I didn't change the references in various files, e.g. in the Resources.resx file. As a result, the namespace Properties could not be found.

I solved the problem by renaming the namespace to its default name.

EDIT: As I read here, the default namespace in the project properties also needs to be changed in order to change the references in all other files too.

Pete Hilde
  • 659
  • 1
  • 10
  • 24
  • God, spent almost an hour on this! Someone thought it would be a good a idea to rename the namespace to "Resources". When changing the file VS changed the namespace to match the correct one and boom - nothing worked anymore. This helped me find the mistake. – jpgrassi May 10 '19 at 11:29
4

Get the Project Properties by right click the project name then select the Resource tab change Access Modifier to public

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 28 '21 at 00:51
  • This solved it for me. I suddenly was having the same problem...don't know how it got set to private but thanks for the post. – Cobysan Jun 23 '22 at 16:37
  • This solved my issue after converting over from VB.NET. – user0123456789 Jan 29 '23 at 21:57
2

I fixed this by going into the Resources.resx file and looked for an entry with the same data name, e. g.:

<data name="buscar" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Imagenes\buscar.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>

I originally added another image with the same name "Buscar". I deleted it and everything went back to normal.

Quality Catalyst
  • 6,531
  • 8
  • 38
  • 62
1

When the Resource.resx file gets all messed up, it's easier to delete it, right click the Properties in solution explorer and create a new Resource file.

David D.
  • 557
  • 7
  • 20