views:

397

answers:

2

I recently upgraded my projects from VS2005 to VS2008. I use a .resx file to store strings and it worked fine with VS2005.

Now, with VS2008, I added a new string to Strings.resx file and used it in my code (C#). But I got a compilation error that my new string doesn't exist in Strings. I asked my colleague to check it on his machine and he got the same problem. I found out that VS2008 add the new string to the .resx file but not to the .Designer.cs file.

Is it a known issue? Is there any way to fix it? (besides adding the code manually to .Designer.cs)

Thanks in advance.

A: 

I've just tried creating a project in VS2005 with a .resx file and then converting it to VS2008, and there are no problems. However I think I have seen this before: in the Solution Explorer in VS2008, are the .resx and the .designer files displayed separately? i.e. there isn't a '+' icon next to the .resx file which will expand to show the .designer file.

If this is the case, I'm sure there's some way of getting VS2008 to treat them as connected files again. Maybe highlight both in Solution Explorer, right-click and see what the options are?

Graham Clark
No, they are displayed together (with +) so that's not the issue here.BTW - I know how to combine files into one in the solution explorer.You can open the .csproj file for editing in notepad, find the file you want to display under another file and make it looks like that: <Compile Include="MyDependantFile.cs"> <DependentUpon>MyOtherFile.cs</DependentUpon> </Compile>
Sharon
+1  A: 

Turns out that the problem occurred because my .resx and .Designer.cs files was read-only after I checked them out from StarTeam.

In VS2005 I was asked if I want to make both files writable and when I answered yes the .Designer.cs file was also modified, so I could access the new member from my code. But in VS2008, it doesn't ask if I want to make the .Designer.cs file writable, so it stays read-only and VS can't modify it, so I can't access the new member.

To summarize: You should always make both .resx file and .Designer.cs file writable before changing the .resx file to make it work correctly with VS2008.

Sharon
EXACTLY the same problem with TrueChange and how when you grab files they are read-only. Thanks for the answer. I was always asked in 2k5, but not in 2k8, as you said.For others, the way to "correct" it once you've already made a new entry (or 2, or 3) is to make the designer writable, then change the KEY in the resx file (and save it) to anything to force a re-write. Then just change it back. You only need to do this for ONE of your values, not all of them, since it does a complete re-process of the file.
Kevin