Dagrooms
Dagrooms

Reputation: 1564

Resources File in .NET Standard (1.4) with New csproj

I'm developing an application targeting .NET Standard 1.4, using the new csproj style (not project.json), and trying to get a localizable resources file to become available throughout the project. I get compiler errors when including a resources file currently, stating that the resources member I'm trying to access is not defined. (Note: my final solution will have to be consumed by a Xamarin Android project and a UWP project)

The csproj automatically includes the resources file as follows:

<ItemGroup>
    <Compile Update="Resources.Designer.cs">
        <DesignTime>True</DesignTime>
        <AutoGen>True</AutoGen>
        <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
</ItemGroup>

<ItemGroup>
    <EmbeddedResource Update="Resources.resx">
        <Generator>ResXFileCodeGenerator</Generator>
        <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
</ItemGroup>

Did it miss a step in the generation? Why can't I access any of the members of my resources file throughout the assembly?

Upvotes: 2

Views: 3381

Answers (1)

Dagrooms
Dagrooms

Reputation: 1564

After pasting resource XML, make an edit to the .resx file to generate the C# class.

.resx files generate the corresponding C# file after editing the .resx. Since I was pasting XML and not making any edits in the .resx file, the class never got generated.

Upvotes: 3

Related Questions