0

I stored some .wav files in the resource folder, but I don't know what the type would it be after Properties.Resources.ResourceManager.GetObject("A.wav")

So I called

MessageBox.Show(Properties.Resources.ResourceManager.GetObject("A.wav").GetType().ToString());

However, it give me an exception on Properties.Resources:

error CS1061: 'PropertyStore' does not contain a definition for 'Resources' and no extension method 'Resources' accepting a first argument of type 'PropertyStore' could be found (are you missing a using directive or an assembly reference?)

Thanks for any help!

////////////////////////////////////////////////////

The answer for this problem is as what Amy provided.

stackoverflow.com/questions/90697/…

The resources folder should been added in property tab but not do it manually.

Jieke Wei
  • 173
  • 2
  • 13
  • A resources *folder*? Or a resources *file*? https://stackoverflow.com/questions/90697/how-to-create-and-use-resources-in-net –  Feb 06 '18 at 21:45

1 Answers1

1

I'm guessing that your Resources.resx file is located in a filesystem directory (or project folder) named Resources, so MSBuild/ResXGenerator will generate your strongly-typed class Resources inside a new namespace that matches the folder path - but this is a problem because you have a local class member also named Properties and that's what's causing the error.

I recommend changing the namespace the class Resources is generated in.

  1. Select Properties/Resources.resx in the Solution Explorer
  2. Open the Visual Studio Properties inspector.
  3. Provide a different namespace in the "Custom tool namespace" field.

A partial cause of this confusion is how in .NET both types (class Resources) and public members (YourClass.Resources) are both in PascalCase which means it's impossible to differentiate by eyesight-alone if an identifier refers to a type or a member. (In Java members are always in camelCase). If YourClass.Properties is an instance member I recommend adopting the convention of always prefixing local instance member access with this..

Dai
  • 141,631
  • 28
  • 261
  • 374