hello to everyone
Excuse me for my horrible English
Link: Create resource files for .NET apps | Microsoft Learn
C Sharp:
I have problems with resource files .resources
I followed the instructions with the example:
The following example uses a resource file in text format named GreetingResources.txt for a simple "Hello World" console application. The text file defines two strings, prompt and greeting, that prompt the user to enter their name and display a greeting.
GreetingResources.txt
A resource file in text format for a "Hello World" application.
Initial prompt to the user.
prompt=Enter your name:
greeting=Hello, {0}!
The text file is converted to a .resources file by using the following command:
resgen GreetingResources.txt
output:
Reading in resources 2 from "GreetingResources.txt".
Writing to resource files in progress.... Completed..:
now the GreetingResources.resources file is in the project
The following example shows the source code for a console application that uses the .resources file to display messages to the user.
using System;
// using System.Reflection; is not used ???
using System.Resources;
public class Example
{
public static void Main()
{
ResourceManager rm = new ResourceManager("GreetingResources",
typeof(Example).Assembly);
Console.Write(rm.GetString("prompt")); // Error**
string name = Console.ReadLine();
Console.WriteLine(rm.GetString("greeting"), name);
}
}
// The example displays output like the following:
// Enter your name: Wilberforce
// Hello, Wilberforce!
Error**
Unhandled exception
'Could not find the resource "GreetingResources.resources" among the resources "" embedded in the assembly "Risorse_03_090721", nor among the resources in any satellite assemblies for the specified culture. Perhaps the resources were embedded with an incorrect name.'
Why doesn't it work?