Welcome to CrankyGoblin.Com Sign in | Join | Help

Public Class GeoffAppleby

Inherits Microsoft.VisualBasic.MVP : Implements IBrainFart
Can I touch it?

A while ago I posted a method of serializing a hashtable. It pretty much comes down to converting the hashtable to an array before it's serialized.

A little after that, I talked about how this is fairly ugly in that you have to do the serialization yourself, rather than get it done automagically by using either a) the right attributes or b) hooking the serialization process. The ISerializable interface doesn't work, unfortunately.

Well I've stumbled across something pretty cool that solves my problem. But it brings extra problems with it. James Crowley posted an article on developer fusion (this link is to his blog post on the article) about hooking the xml serializer so that instead of having to explicitly perform the serialization yourself, you instead get called to provide your XML when required.

It ends up that the IXMLSerializable interface is exactly what I was looking for. If your class implements this, then when you are XML serialized, the methods you implement let you write your own XML out - and the cool thing is that you aren't limited to public properties anymore either. You can write out whatever you like. Along with this, you have to read your XML back in at deserialization time.

In the article, James mentions that this interface in the 1.1 framework is undocumented, and he hopes that in whidbey it will be there.

Well, maybe I scare easier than he does. In the 1.1 MSDN documentation, they actually say it shouldn't be used directly inside your code. In the beta version of the whidbey MSDN documentation, it's fully documented (ok, they haven't finished the examples yet, but you get the point).

This gives me a bit of a problem. I'd love to use it. Thanks to both James' article and the beta MSDN doco, I now know how to use it. I get the feeling that I'm going to have to actually return a schema if i want to pass the class across a webmethod (so the WSDL can generate properly), but that's ok.

So should I use it? On the one hand they say don't, on the other they are almost saying I can. Should i wait for the 2.0 framework to come out first? Other people have had success with it in the past - James obviously did, and this article on dotnetified shows someone (it's not clear, I think his name is Andy Hopper) who had great success with it back in May 2003. Also, Daniel Cazzulino has talked a bit about how the XMLSerializer works, which is pretty cool. See? Now that I have something to search against, I can find out a lot about it :)

But I need someone, preferably from MS, to pat me on the back and say 'It's OK, go shoot yourself in the foot'. Maybe it's time I mailed my ISV Buddy. We haven't spoken in a while. :)

Listening to: pathetic - blink 182 - (2:27)
Posted: Saturday, December 18, 2004 5:29 PM by Geoff Appleby

Comments

James Crowley said:

My attitude is pretty much - if it works in .NET 1.1, undocumented - and it's going to be in .NET 2.0, documented.... then it's probably pretty safe. (famous last words... :p)
# December 18, 2004 1:47 PM

Geoff Appleby said:

Wow. James, you found me pretty fast!
I was going to let you know that I'd quoted you - but I can see now i don't need to bother :) There's a use for trackbacks afterall, i guess!
# December 18, 2004 1:53 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

To submit your comment, click on these pictures:
  • Geoff's foot
  • Angry Geoff
  • Geoff's dad's tongue
Gaptcha Image - No Peeking! Gaptcha Image - No Peeking! Gaptcha Image - No Peeking!
Gaptcha Image - No Peeking! Gaptcha Image - No Peeking! Gaptcha Image - No Peeking!
Gaptcha Image - No Peeking! Gaptcha Image - No Peeking! Gaptcha Image - No Peeking!
Can't recognise the people in these pictures? Look here for a quick introduction.
There's a time limit for you to get your comment submitted before this set of pictures expires. If you think it's been longer than 10 minutes, get some new pictures first (you won't lose what you've typed so far).
Get some new pictures 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS