[Mono-dev] Custom surrogates and serialization
mono at kinitos.com
Fri Sep 2 11:49:27 EDT 2005
I've recently started a project trying to get some fairly complex
software that was written for .Net 1.1 working on Mono, and so far I've
found almost everything works quite well with minimal changes needed.
I have run into a few issues, and I’m hoping that someone can take a
look at them. I was able to boil down a few into small test cases, and
I've filed some bugs with my test cases attached (#75947 and #75950).
Please let me know if I need to provide more information for these issues.
I'm now working on some problems with Xml serialization, and this is
where the bulk of the problems I'm getting have been. The first is that
our software uses a custom serializer surrogate for
System.Net.IPAddress, in order to handle differences between .Net 1.0
and 1.1. On Mono, our custom serializer doesn't work; it gets the error
"The attempted operation is not supported for the type of object
referenced" instead. My surrogate code is:
public object SetObjectData(
System.String ipStr = info.GetString( "address" );
= System.Net.IPAddress.Parse( ipStr );
System.Net.IPAddress ipAddress = (System.Net.IPAddress)obj;
// This line throws the exception
ipAddress.Address = newIP.Address;
The problem seems to be that when the deserializer creates the new
IPAddress object the AddressFamily field ends up uninitialized, and the
Address property set fails.
Unfortunately the deserializer also mimics the .Net 1.0 behaviour where
the return value of SetObjectData is ignored, so I can't just create a
new IPAddress and return it instead (in .Net 1.1, this bug is supposedly
I've got a few more issues I've found in the SOAP serializer using
surrogates, but I'm still working on tracking them down.
Thanks for any information anyone can provide!
More information about the Mono-devel-list