[Mono-winforms-list] Possible bug with ResxResourceReader class

Robert Jordan robertj at gmx.net
Tue Oct 3 09:53:05 EDT 2006


Gideon de Swardt wrote:
> Hi All
> 
> I think I found a bug in the ResxResourceReader. If a resx file
> contains a resource of the type System.Drawing.Bitmap, the reader
> fails to to read the specific item. I have attached a test file as
> well as test program that first use a patched version of the
> ResxResourceReader to successfully load the resx file and then
> secondly tries to load it with the current ResxResourceReader in the
> Mono runtime.
> 
> I have also included a patch file for fixing this bug. Please review

The resource file you've attached can't be correctly read by MS.NET 2.0,
so I doubt this is a bug.

When I try to read the resource on MS.NET 2.0 with the following
code, I get "true". This means that MS.NET was not able to deserialize
the value.

using System;
using System.Collections;
using System.Resources;

class MainClass
{
         static void Main ()
         {
                 ResXResourceReader reader =
                         new ResXResourceReader("test.resx");

                 foreach (DictionaryEntry e in reader) {
                         string key = (string) e.Key;

                         if (key == "WebReference.File.Wsdl.png") {
                                 Console.WriteLine (e.Value == null); 
                      }
                 }

                 reader.Close();
	}
}


If I apply the attached patch to Mono's ResxResourceReader
it will be able to deserialize such values, but that's not
compatible with MS.NET, so it's rather useless.

MS.NET seems to use binary serialization for System.Drawing.Bitmap.
It generates the attribute

mimetype="application/x-microsoft.net.object.bytearray.base64"

which can be deserialized by Mono w/out any trouble.

Robert

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ResXResourceReader.diff
Url: http://lists.ximian.com/pipermail/mono-winforms-list/attachments/20061003/8d1ec4a5/attachment.pl 


More information about the Mono-winforms-list mailing list