[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pnet-developers] ResourceWriter generates invalid .resources file
From: |
Bruno Haible |
Subject: |
[Pnet-developers] ResourceWriter generates invalid .resources file |
Date: |
Mon, 29 Dec 2003 12:41:31 +0100 |
User-agent: |
KMail/1.5 |
Using pnet-0.6.0.
The ResourseWriter generated .resources files are not understood by
either
- pnet's resgen utility,
- pnet's ResourceReader class,
- mono's monoresgen utility,
- mono's ResourceReader class.
The resgen generated .resources files are OK in all four situations.
To reproduce:
=============================== hello.cs ========================
using System;
using System.Resources;
class Hello {
static void Main () {
ResourceWriter rw = new ResourceWriter("foo.resources");
rw.AddResource("Simple", "Einfach");
rw.Generate();
rw.Close();
}
}
==================================================================
$ cscc hello.cs -o hello.exe
$ rm -f foo.resources
$ ilrun hello.exe
$ resgen foo.resources foo.po
foo.resources: invalid offset to resource value
$ monoresgen foo.resources foo.po
Error: Malformed .resources file (padding values incorrect)
A hex dump reveals two oddities:
- differences in the encoding of the keys (UTF-16 versus UTF-8),
- a hash code (EB 91 C2 C7) that is written twice instead of once.
================== foo.resources generated by pnet resgen (GOOD) =========
000000 CE CA EF BE 01 00 00 00 58 00 00 00 29 53 79 73 ........X...)Sys
000010 74 65 6D 2E 52 65 73 6F 75 72 63 65 73 2E 52 65 tem.Resources.Re
000020 73 6F 75 72 63 65 52 65 61 64 65 72 2C 20 6D 73 sourceReader, ms
000030 63 6F 72 6C 69 62 2D 53 79 73 74 65 6D 2E 52 65 corlib-System.Re
000040 73 6F 75 72 63 65 73 2E 52 75 6E 74 69 6D 65 52 sources.RuntimeR
000050 65 73 6F 75 72 63 65 53 65 74 2C 20 6D 73 63 6F esourceSet, msco
000060 72 6C 69 62 01 00 00 00 01 00 00 00 01 00 00 00 rlib............
000070 17 53 79 73 74 65 6D 2E 53 74 72 69 6E 67 2C 20 .System.String,
000080 6D 73 63 6F 72 6C 69 62 EB 91 C2 C7 00 00 00 00 mscorlib........
000090 A5 00 00 00 0C 53 00 69 00 6D 00 70 00 6C 00 65 .....S.i.m.p.l.e
0000a0 00 00 00 00 00 00 07 45 69 6E 66 61 63 68 .......Einfach
==========================================================================
================== foo.resources generated by program above (BAD) ========
000000 CE CA EF BE 01 00 00 00 58 00 00 00 29 53 79 73 ........X...)Sys
000010 74 65 6D 2E 52 65 73 6F 75 72 63 65 73 2E 52 65 tem.Resources.Re
000020 73 6F 75 72 63 65 52 65 61 64 65 72 2C 20 6D 73 sourceReader, ms
000030 63 6F 72 6C 69 62 2D 53 79 73 74 65 6D 2E 52 65 corlib-System.Re
000040 73 6F 75 72 63 65 73 2E 52 75 6E 74 69 6D 65 52 sources.RuntimeR
000050 65 73 6F 75 72 63 65 53 65 74 2C 20 6D 73 63 6F esourceSet, msco
000060 72 6C 69 62 01 00 00 00 01 00 00 00 01 00 00 00 rlib............
000070 5D 53 79 73 74 65 6D 2E 53 74 72 69 6E 67 2C 20 ]System.String,
000080 6D 73 63 6F 72 6C 69 62 2C 20 56 65 72 73 69 6F mscorlib, Versio
000090 6E 3D 31 2E 30 2E 35 30 30 30 2E 30 2C 20 43 75 n=1.0.5000.0, Cu
0000a0 6C 74 75 72 65 3D 6E 65 75 74 72 61 6C 2C 20 50 lture=neutral, P
0000b0 75 62 6C 69 63 4B 65 79 54 6F 6B 65 6E 3D 62 37 ublicKeyToken=b7
0000c0 37 61 35 63 35 36 31 39 33 34 65 30 38 39 00 00 7a5c561934e089..
0000d0 EB 91 C2 C7 EB 91 C2 C7 E7 00 00 00 06 53 69 6D .............Sim
0000e0 70 6C 65 00 00 00 00 00 07 45 69 6E 66 61 63 68 ple......Einfach
==========================================================================
Suggestion: Change the ResourceWriter to match the algorithm employed by
resgen utility.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pnet-developers] ResourceWriter generates invalid .resources file,
Bruno Haible <=