Search code examples
c#resxcompiler-errors

New string added to .resx file in VS2008 cause compilation error that it doesn't exist


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.


Solution

  • 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.