Swapping .Net resources |
Swapping the resources in your assembly for resources of another languageThis process will take your English main assembly; disassemble it into a text file and any English .resources sections found. After this you can replace the resources sections with those of your chosen language (the localised .resources sections are a by-product of the satellite extraction in Catalyst) Finally you stitch the text file and the correct resource sections back together to recreate the main assembly with the new resources embedded UtilitiesYou will need the following tools: MSIL Disassembler Ildasm.exe which takes a portable executable (PE) file containing Microsoft intermediate language (MSIL) code (i.e. a .NET assembly) and creates a text file and a .resources file for each resource section it finds in the assembly. The text file may be used later with a different bunch of .resources files to recreate a different assembly. The MSIL Assembler, Ilasm.exe, generates a portable executable (PE) file from Microsoft intermediate language (MSIL). This tool will take the text file from the disassembler above and creates a new assembly. It will embed the .resources files that it finds without being fussy about their language! ProcessStep 1 Disassembly Input: .NET Assembly Output: Text file and a .resources file for each resource section found. A Win32 *.res file is also created Syntax: C:\Test>ildasm.exe /output=C:\Project\WindowsApplication1.IL WindowsApplication1.exe This creates a text file containing MSIL Also created is a default language .resources file for each resource section found. One such file might be called WinApp1.Form1.resources Step 2 Swap .resources When extracting a localised assembly in Catalyst, the satellite assembly is created in the specified folder, along with all localised .resources files. These will have a name such as WinApp1.Form1.de-de.resources To make these appear language neutral, the language appendage is removed, so the file becomes WinApp1.Form1.resources Now replace the default language .resources created in Step 1 with these localised ones
Step 3 Reassembly Input: Text file and a .resources file for each resource section required Output: .NET Assembly Syntax: C:\Test>ilasm.exe /EXE C:\Project\WindowsApplication1.IL /OUTPUT=WinApp1.exe /RESOURCES=WindowsApplication1.res The /RESOURCES="WindowsApplication1.res" switch embeds the win32 resource back into the resulting assembly. There is no requirement to specify the .resource files. They are referenced in the MSIL and get included automatically. ResultA new assembly that will run with localised content regardless of the user locale or regional settings.
Products or Versions Affected
|