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
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,913 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,159 questions
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 65,131 Reputation points
    2021-12-31T17:16:25.42+00:00

    See docs on naming resources

    https://video2.skills-academy.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.