Reproduced http://hi.baidu.com/heiru/blog/item/fb62922359ef0c4dad34de96.html
Today, when I was testing a project, I suddenly encountered such a problem:
Error message: system. Resources. missingmanifestresourceexception: failed to find any resources that are suitable for the specified region or non-specific region. Make sure that "*****. ****. resource. resources "is correctly embedded or linked to the assembly" ***** ", or make sure that all required ancillary assembly is loaded and fully signed.
I haven't seen several articles on solution after searching for N for a long time on the Internet, and finally solved it with unremitting efforts. So I decided to write down the solution to my friends who encountered the same problem in the future:
In fact, the main problem with this error is that the required resource file (this file is resources. resx) is not found ),
Where the file is referenced
System. Resources. ResourceManager manager = new system. Resources. ResourceManager ("×××. Resources", typeof (resources). Assembly );
The cause of the error is that the configuration of "XXX. Resources" is incorrect.
Solution: First, check that resources. resx files exist in the project,
Locate its position in the project (generally in the project name. properties namespace ),
Finally, change the configuration to new system. Resources. ResourceManager ("project name. properties. Resources", typeof (resources). assembly );
Continued:
Here is a detailed example for better understanding.
First, if a container (whether form or panel) matches a resource file (with the suffix. resx), then the two files should be in the same namespace to use each other
The most special example
For example, a project named test. tname
There is a folder named AAA under it (the folder name is casual, It Doesn't Matter)
Under the folder AAA, there is a class file named form1.cs whose namespace is test. tname (Note: The namespace is the important location information)
There is also a resource file named form1.resx.
(By default, this resource file is correct, but under special circumstances, this file will no longer be in the correct position, resulting in abnormal information such as the question, for example, I decompile a project, the location of the automatically generated resource file is incorrect ).
The code in form1.cs requires resource files.
ResourceManager manager = new ResourceManager (typeof (test. tname. form1 ));
Note that if the form1.cs class file and the form1.resx resource file are separated,
So where should the form1.resx resource file be stored before the program can find it?
First, we can see that the namespace of the HA form1.cs class file is test. tname.
The resource file form1.resx does not have a namespace description, so it is only represented by location.
Let's take a look at our Project name: Test. tname is very good, it is the same as the namespace of the form1.cs class file
So we put the form1.resx resource file under the root directory of the project.
Solved the problem.
In fact, I think the most important problem is that the class file can contain namespaces to describe the location.
The resource file does not have this line of code, and it can only rely on the real location. This is the key