When I try 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'
The code that produces the error is:
string s = MyClass2.Properties.Resources.TestString2;
The really bizarre thing is that another project in my solution (using MyClass and TestString) with exactly the same setup does NOT produce the error and works like a champ. Here is the background and all the things I have tried.
- Both are plain "Class Library C#" projects in VS2008.
- I created the resource strings via right-click->Properties for each project in the solution tree, then selecting the "Resources" tab. Then I just entered a "TestString" in one, and a "TestString2" in the other.
- For the project that works, if I type MyClass. - the IDE IntelliSense tells me that "Properties" is an available member (but that is the ONLY member it shows me). For the project that doesn't work, the available members are "Equals" and "ReferenceEquals" (it does NOT give me "Properties"). This seems to be the biggest clue that SOMETHING is different.
- Thinking my project files got corrupted, I completely created both projects again 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 up VS2008 again and used File->New->"Project From Existing Code..." to create new projects. Then I added the resources in exactly the same way for both projects (per Step 2 above). Same results.
- I have performed a 'diff' on the corresponding files between the two projects (Resources.resx, Resources.Designer.cs, MyProj.csproj). Nothing looks different other than what I would expect (class names and string names differ between them).
- I've googled it to death. Based on how bizarre this feels, there's no doubt I've done something insanely stupid (see http://stackoverflow.com/questions/58640/great-programming-quotes/756768#756768).