Localizing CrystalReportViewer
I'm describing here the procedure how to localize CrystalReportViewer in .NET 1.1 framework, in an _almost_ proper way (i.e., we actually create a satellite assembly containing resources). We have to do some hacking though, because the assembly containing the English resources is strong-named, so the satellite assemblies ought to be signed by the same private key which we obviously do not have.
I will assume that you are familiar with "programming" in Command prompt and are skilled enough to solve possible problems yourself. Use at your risk only.
I'm doing this for Windows Forms version of CrystalReportViewer. I guess the same could be done for Webforms. Only replace "Windows.Forms" with "Web", and "CRViewerSys" with "ViewerSys" in all filenames.
Step 1: Extracting the resources
- Create a working directory, e.g., C:\crystalresources, and copy the file "C:\Program Files\Common Files\Crystal Decisions\1.1\Managed\CrystalDecisions.Windows.Forms.dll" (or wherever it is located) to the created directory
- Run Visual Studio .NET 2003 Command Prompt from the start menu, and change the current directory (I assume in all the following snippets that you are located in C:\crystalresources):
cd C:\crystalresources
- Disassemble the assembly. Don't extract the code, we are interested only in the resources.
ildasm CrystalDecisions.Windows.Forms.dll /OUT=CrystalDecisions.Windows.Forms.il /ITEM=
- Convert the resources to the XML format.
resgen CrystalDecisions.Windows.Forms.CRViewerSys.resources CrystalDecisions.Windows.Forms.CRViewerSys.resx
- You may delete all files in C:\crystalresources except the .resx, .il, and .dll, since we'll need them later.
Step 2: Creating the satellite assembly
- Compile the created resource file:
resgen CrystalDecisions.Windows.Forms.CRViewerSys.CULTURE.resx CrystalDecisions.Windows.Forms.CRViewerSys.CULTURE.resources
- Create the directory C:\vs7\keys, and create a fake key:
sn -k C:\vs7\keys\crystalpublickey.snk
- Create the satellite assembly
al /embed:CrystalDecisions.Windows.Forms.CRViewerSys.CULTURE.resources /out:CrystalDecisions.Windows.Forms.resources.dll /template:CrystalDecisions.Windows.Forms.dll /culture:CULTURE
- Disassemble the created file:
ildasm CrystalDecisions.Windows.Forms.resources.dll /out=CrystalDecisions.Windows.Forms.resources.il
- Open the file "CrystalDecisions.Windows.Forms.il" in the notepad and copy the part containing the public key, something like:
.publickey = (00 00 00 ..... // ... ... // ... ... // ... AA AA AA ... ) // ...
to the clipboard. - Open the file CrystalDecisions.Windows.Forms.resources.il in the notepad, and replace the publickey block (remove the old part and paste new there).
- Compile the file.
ilasm /dll CrystalDecisions.Windows.Forms.resources.il
- Now fool the framework not to check the public key, like described here: http://www.grimes.demon.co.uk/workshops/fusionWSCrackOne.htm. So download snSig.cs and alterSn.cs to C:\crystalresources and execute:
csc /t:library snSig.cs csc alterSn.cs /r:snSig.dll alterSn CrystalDecisions.Windows.Forms.resources.dll
- Create the subdirectory CULTURE in your application directory (where your .exes and .dlls reside). Copy CrystalDecisions.Windows.Forms.resources.dll to that directory.