Search code examples
c#.netc#-4.0.net-4.0embedded-resource

Adding string to embedded resources file stops project from compiling


A resources file is compiled as an embedded resource in Project1. Strings are accessed code by:

Resources.ResourcesFileName.ResourceManager.GetString("Resource1");

Project1 compiles and works fine. I cleaned before building to confirm.

When I add another string to the resource, (TFS checks out the file) Project1 no longer compiles.

'ResourcesFileName' is not a member of 'Resources'.

How can I get this to compile again with the additional resource string?


Solution

  • Someone must have changed the Custom Tool Namespace (Select resource file -> Properties -> Custom Tool Namespace) from My.Resources to Resources.

    This generates a class and file ResourcesFileName.Designer.cs file with a namespace of Resources.

    They then checked in the resource file and the designer file. However, somehow they checked in the csproj without the correct customtoolnamespace:

    <EmbeddedResource Include="Resources\ResourceFileName.resx">
      <CustomToolNamespace>My.Resources</CustomToolNamespace>
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>ResourceFileName.Designer.cs</LastGenOutput>**
    </EmbeddedResource>