EDN Admin
Well-known member
I am working on upgrade a VS 2008 C++ cli project with targetd framework .net 2.0 to VS 2010 with .net 4.0. This project belongs to one huge solution.
It contains some managed resource files, one .resx under each culture folder like us and fr. Only one of the resources is not Excluded From Build, e.g., the one under fr is excluded when the culture is us. We are using Pre-build event to call ResGen.exe
to generate .resources file for the current resource, the us one.
In VS 2008,
1. it works well with only one single <projectname>.<resourcefilename>.resources generated after compilation, and we can see it in manifest of the project dll with ildasm.exe.
2. The resource files were using "Managed Resource Compiler" build tool and with Resource File Name specified. Then Output File Name and Default Localized Resources had default values in gray. We can see auto generated Command Line. Please see the figure
below of .resx file properties in VS2008.
<img src="http://social.microsoft.com/Forums/getfile/15826/" alt="
But in VS2010,
1. it always generates one .resources file for each .resx file instead of generated one single in 2008, e.g., <projectname>.fr.<resourcefilename>.resources for the one under fr, and another for the one under us, even though the fr one is excluded
from build for current config.
2. Managed Resourcess Output File Name and Default Localized Resources have no default values and still keep gray. Comand Line also disappears. I dont know how it is compiling the managed resource or it does not compile it at all.
This lead to string resources retrieving failure through resource manager. The first error message looks like below. The projectname.resources is never generated in any VS version and not supposed to be used at all.
<span style="font-family:Consolas; font-size:xx-small <span style="font-family:Consolas; font-size:xx-small
A first chance exception of type System.IO.FileNotFoundException occurred in mscorlib.dll
Additional information: Could not find file projectname.resources.
I searched a lot in Internet and tried several solutions. None of them works for me.
The solutions Ive tried in VS2010:
1. I replaced $(InputName) with $(Filename) as someone from MS suggested when he answered some relative question. Nothing help.
2.
a. I set Item type of the fr resource to "Does not participate in build" since Exclude from Build is not preventing it from build. Yes, this change makes the **.fr.*.resources disappeare. So I do the same thing to the us resource to make **.us.*.resources
disappear.
b. And I set Linker->Input->Embed Managed Resource File value to the .resources file generated by pre-build event. Yes, this makes the project dll manifest only contains one resource declaration as follows just like it looks in 2008.
Manifest in project dll viewed by ildasm.ext:
<span style="font-size:small
.mresource public projectname.Resources.resources
{
// Offset: 0x00000000 Length: 0x00000A4C
}
<span style="font-size:small <span style="font-size:small
While with these series of changes, the running result is still the same, the FileNotFound error shows again. Its still looking for <projectname>.resources which doesnt exist at all.
<span style="font-size:small 3. I also tried to compile the <projectname>.<resourcefilename>.resources to <projectname>.resources.dll with al.exe, and set Linker->Input->Assembly Link Resource to this dll. The result is
the same with solution 2.
I guess my problem is caused by some changes on managed resource setting or compilation introduced by VS2010. But I didnt find a valid complete answer yet.
Thanks a lot if you can help.
<span style="font-size:small <br/>
<br/>
<span style="font-size:small <span style="font-size:small
View the full article
It contains some managed resource files, one .resx under each culture folder like us and fr. Only one of the resources is not Excluded From Build, e.g., the one under fr is excluded when the culture is us. We are using Pre-build event to call ResGen.exe
to generate .resources file for the current resource, the us one.
In VS 2008,
1. it works well with only one single <projectname>.<resourcefilename>.resources generated after compilation, and we can see it in manifest of the project dll with ildasm.exe.
2. The resource files were using "Managed Resource Compiler" build tool and with Resource File Name specified. Then Output File Name and Default Localized Resources had default values in gray. We can see auto generated Command Line. Please see the figure
below of .resx file properties in VS2008.
<img src="http://social.microsoft.com/Forums/getfile/15826/" alt="
But in VS2010,
1. it always generates one .resources file for each .resx file instead of generated one single in 2008, e.g., <projectname>.fr.<resourcefilename>.resources for the one under fr, and another for the one under us, even though the fr one is excluded
from build for current config.
2. Managed Resourcess Output File Name and Default Localized Resources have no default values and still keep gray. Comand Line also disappears. I dont know how it is compiling the managed resource or it does not compile it at all.
This lead to string resources retrieving failure through resource manager. The first error message looks like below. The projectname.resources is never generated in any VS version and not supposed to be used at all.
<span style="font-family:Consolas; font-size:xx-small <span style="font-family:Consolas; font-size:xx-small
A first chance exception of type System.IO.FileNotFoundException occurred in mscorlib.dll
Additional information: Could not find file projectname.resources.
I searched a lot in Internet and tried several solutions. None of them works for me.
The solutions Ive tried in VS2010:
1. I replaced $(InputName) with $(Filename) as someone from MS suggested when he answered some relative question. Nothing help.
2.
a. I set Item type of the fr resource to "Does not participate in build" since Exclude from Build is not preventing it from build. Yes, this change makes the **.fr.*.resources disappeare. So I do the same thing to the us resource to make **.us.*.resources
disappear.
b. And I set Linker->Input->Embed Managed Resource File value to the .resources file generated by pre-build event. Yes, this makes the project dll manifest only contains one resource declaration as follows just like it looks in 2008.
Manifest in project dll viewed by ildasm.ext:
<span style="font-size:small
.mresource public projectname.Resources.resources
{
// Offset: 0x00000000 Length: 0x00000A4C
}
<span style="font-size:small <span style="font-size:small
While with these series of changes, the running result is still the same, the FileNotFound error shows again. Its still looking for <projectname>.resources which doesnt exist at all.
<span style="font-size:small 3. I also tried to compile the <projectname>.<resourcefilename>.resources to <projectname>.resources.dll with al.exe, and set Linker->Input->Assembly Link Resource to this dll. The result is
the same with solution 2.
I guess my problem is caused by some changes on managed resource setting or compilation introduced by VS2010. But I didnt find a valid complete answer yet.
Thanks a lot if you can help.
<span style="font-size:small <br/>
<br/>
<span style="font-size:small <span style="font-size:small
View the full article