Invalid names for embedded resources in .NET assembly

Roberto 41 Reputation points
2021-12-30T08:43:02.237+00:00

Trying to include in a project somes .json files as embedded resources I found that some names are not managed by .NET runtime.
It seems that names that ends with a language acroym and an extension are not compiled as embedded resources.

e.g in a project with following embedded files:

<ItemGroup>
<None Include="App.config" />
<EmbeddedResource Include="CustomizableResources.RU_.json" />
<EmbeddedResource Include="CustomizableResources.other.json" />
<EmbeddedResource Include="Anything.RU.json" />
<EmbeddedResource Include="other.RU.mp3" />
<EmbeddedResource Include="other_RU.json" />
<EmbeddedResource Include="other.RU.json" />
<EmbeddedResource Include="CustomizableResources.RU.json" />
<EmbeddedResource Include="CustomizableResources.IT.json" />
</ItemGroup>

If I recall

var assembly = typeof(Program).Assembly;
var resourNames = assembly.GetManifestResourceNames();

I get only this resources:

  • TestGetManifestResourceNames.CustomizableResources.RU_.json
  • TestGetManifestResourceNames.CustomizableResources.other.json
  • TestGetManifestResourceNames.other_RU.json
Developer technologies .NET .NET Runtime
Developer technologies C#
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2021-12-31T17:16:25.42+00:00

    See docs on naming resources

    https://learn.microsoft.com/en-us/dotnet/core/resources/manifest-file-names

    The .IT. and .RU. In your names are identified as culture names, and as they are not the current default culture, are not returned in the list.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.