For C # resources, why is Properties undefined?

When I try to try to access a string property in one of my C # project resources, I get the following error:

'ORG.PRJ.MOD.MyClass2' does not contain a definition for 'Properties'

      

Code generating the error:

string s = MyClass2.Properties.Resources.TestString2;

      

It's actually strange that another project in my solution (using MyClass and TestString) with the exact same setup does NOT produce an error and works like a champion. Here's the backstory and everything I've tried.

  • Both are simple C # Class Library projects in VS2008.
  • I created resource strings by right clicking-> Properties for each project in the decision tree, then selecting the Resources tab. Then I just typed "TestString" into one and "TestString2" into the other.
  • For a project that works if I type in MyClass. - The IntelliSense IDE tells me that "Properties" is an accessible member (but it is ONLY the member it shows me). For a project that doesn't work, the available members are "Equals" and "ReferenceEquals" (it does NOT give me "Properties"). This appears to be the biggest clue that SOMETHING is different.
  • Thinking that my project files were corrupted, I completely created both projects from scratch. I deleted all bin, obj and Properties folders, deleted all Resources.resx and Resources.Designer.cs files, deleted all .csproj, .csproj.user, .sln and .suo files. For BOTH projects. Then I started VS2008 again and used File-> New → "Project From Existing Code ..." to create new projects. Then I added resources in exactly the same way for both projects (in step 2 above). Same results.
  • I have performed a "diff" on the respective files between the two projects (Resources.resx, Resources.Designer.cs, MyProj.csproj). Nothing looks different than what I expect (class names and string names differ between them). In the meantime, there is no need to know about it. ”
  • I killed him to death. Based on how strange this is, I have no doubt that I did something insanely stupid (see https://stackoverflow.com/questions/58640/great-programming-quotes/756768#756768 ).
+2


source to share


1 answer


The static class Properties

is available through the default namespace for your project. Now, given that this is a class library that might be Class2

(or maybe there might be a name clash, that is, with Class2.Class2

), but something tells me that this is a class in your library, not a namespace (which will create the error you described).



+6


source







All Articles