question

Sergio-9977 avatar image
0 Votes"
Sergio-9977 asked Sergio-9977 answered

Could not find the resource

Hello to all
I have a problem with a sample C # resource program.

Program link: https://docs.microsoft.com/it-it/dotnet/api/system.resources.neutralresourceslanguageattribute?view=net-5.0

I follow all the instructions, I do all the builds, but when I run the program, it crashes with the following error:
System.Resources.MissingManifestResourceException: 'Could not find the resource "ExampleResources.resources" among the resources "" embedded in the assembly "Example", nor among the resources in any satellite assemblies for the specified culture. Perhaps the resources

Where is the problem?
Thanks

dotnet-csharp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Sergio-9977 avatar image
0 Votes"
Sergio-9977 answered
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TimonYang-MSFT avatar image
0 Votes"
TimonYang-MSFT answered Sergio-9977 commented

I reproduced your problem but haven't found a solution yet.

But there is another way to add resources, right click on the project=> Add=> New Item=>Resources File.

130695-capture.png

Then slightly modify the code in the document:

             string[] cultures = {  "en-us", "fr-FR" };
             Random rnd = new Random();
             int index = rnd.Next(0, cultures.Length);
             Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(cultures[index]);
             Console.WriteLine("The current culture is {0}",
                               CultureInfo.CurrentUICulture.Name);
    
             string grtting = ExampleResources.Greeting;
    
             Console.Write("Enter your name: ");
             string name = Console.ReadLine();
             Console.WriteLine("{0} {1}!", grtting, name);
             Console.ReadKey();

If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


capture.png (8.1 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Such a great site!
I just wanted to tell Timon Yang not to answer a question if he doesn't know the answer.

0 Votes 0 ·