Customize XML Serialization using IXmlSerializable

XML Serialization in .NET provides an incredibly useful (and easy) way to turn objects into XML and back again. However, in some situations, you may need more control over how your object is serialized. Recently, I found myself needing to serialize an object that contained a number of property name/values – stored using a NameValueCollection. However, you can’t serialize this using the XmlSerializer class in .NET. I could have switched to using an array  – at least for the serialization part – but this would have serialized the whole lot as a series of elements – and I wanted to do this using attributes.

[Apologies – I’ve had to snip the code from here, as the layout kept messing around]

Read more here: Customize XML Serialization using IXmlSerializable.

Home for Christmas

I’m back home for Christmas now (yes, I know – its barely december… what can I say…?), so I thought I’d finally update my various blogs! It’s been a busy past few months…

In mid-October, I attended the first Microsoft “Connect” event held in Barcelona. The idea behind this was to bring together community leaders from around Europe – along with Microsoft – to discuss what Microsoft can do to help the communities, and to promote their new Codezone initiative. Around 80 people attended, half of which were community leaders. It was a great few days, with some very interesting debates sparking off. The weather was gorgeous too – I took the opportunity to stay on for a few days to see the sights – though had to downgrade from the hotel Microsoft put us up in to a somewhat less classy hostel!

Next up (literally 2 days after getting back from Barcelona) was the first Microsoft Student Partner meeting of the 04/05. For those of you unfamiliar with the programme – it basically targets the most enthusiastic students around the UK taking Computer-related degrees, and encourages them to promote Microsoft initiatives such as the Imagine Cup and MSDN AA – with a few goodies such as a years MSDN Universal subscription to help them on their way! The first day included some team building exercises to break the ice – these actually worked very well, despite my initial scepticism – plus an evening out in Reading (with an almost-open bar). Unfortunately I had to miss the second day of the more interesting technology stuff, but it was great fun – thanks to everyone in the Academic team for a great day!

Towards the end of November we had the third community leaders meeting in the UK. The meeting in Barcelona really made me appreciate how ahead of the game the UK DPE team are – so thanks go out to them once again! During the day we were updated as to what the other community leaders in the UK have been up to – and what Microsoft has been up to on our behalf. We also had a 30 minute slot with Alistair Baker – MD of Microsoft UK, and a marketing session discussing how to write “copy’ that had been requested at earlier meetings. There were also further discussions as to what exactly Codezone should be – especially in the UK where the language issue simply doesn’t apply, given our easy access to a wealth of material in the states.

The following week I headed off to Copenhagen to discuss just that,with a smaller group of community “influencers’ around Europe,and a collection of Microsoft people, including the Codezone program manager Doug Seven (of dotnetjunkies and sqljunkies). It’s been great that Microsoft are actually bothering to ask the community how best they can support us – rather than assuming whatever they do is good for everyone! During the meeting we bashed out the various issues of how to make sure Codezone supports the existing communities as best as possible, without competing – how best to support federating content on the site, what features the codezone platform should offer to third party sites, how offline events can be promoted, and whether the site should be used to track things such as individual’s contributions to the community. As soon as I’ve got a proper summary of everything discussed, I’ll post it here! Also, keep an eye on Doug’s blog.

So, time for a bit of relaxation now! I’m also starting to vaguely plan a 6 month trip around the world – but sadly not until early 2006! I figured after exams every summer for the last 7 years, I’ll deserve a break!

MSDN Connection (UK)

Microsoft launched a revamped UK MSDN site yesterday, featuring a new “MSDN Connection” service. This basically allows you to customize the MSDN portal according to the technologies and programming languages you’re interested in. And even better…. you get an RSS feed too! 😀

Definitely worth signing up if you’re a UK developer! Take a look here: http://www.microsoft.com/uk/msdn/ 

Yet more ASP.NET 2.0 & Generics

Continuing on my ASP.NET 2.0/Generics adventure…. there also seems to be no way to specify that a Page or UserControl inherits from a class with a type parameter using the Inherits attribute – and doing this in the code doesn’t work, as the partial class declarations end up specifying different base classes.

Am I missing something elementary here?

Generics in ASP.NET 2.0?

I’ve finally gotten around to having a closer look at the current Whidbey beta – particularly from the ASP.NET angle. However, I’ve got a fairly straightforward question that so far I haven’t been able to find any answer to – or even the slightest hint of one. Suppose I want to create a custom Web Control, that accepts a type parameter so that, for instance, we can provide a strongly typed DataItem property.

Obviously you can create an instance of this object by doing

this.Controls.Add(new SomeGenericControl<SomeObjectType>());

in the page load event, but at the moment there doesn’t seem to be a way to define this in the aspx page, along the lines of

<vc:SomeGenericControl : SomeObjectType runat=”server” />

or equivalent. Is this something that just hasn’t made the current beta, or is that syntax not going to be included at all?

CodeZone UK Launched

For all you UK developers out there – CodeZone UK was officially launched during the TechEd Europe conference, after a lot of work on Microsoft’s part (with a little bit of help from community leaders to provide some initial content!) As of last Friday the site now indexes content from both Developer Fusion and DNJ online, and hopefully many more as the site grows.

CodeZone UK was launched to bring together the individual developer community groups in the UK – from developer web sites to user groups – into a central repository. If all goes to plan, it will become a great resource of information of upcoming events across the UK, and new articles and other resources by UK authors.

If you run a User Group or website and are based in the UK, then please do register on the site and start submitting information! And if you’re a developer in the UK, then keep your eye out! The site has a few rough edges at the moment, but we’ll be working hard to make this a valuable resource for everyone in the UK.

If you’re elsewhere in Europe, and haven’t already found your country’s CodeZone site, then check out http://www.codezone.info/ . You can subscribe to the free magazine too.

Holiday!

Well, I’m now off Uni for 3 months over the summer, which should mean I’ll finally get time to code my ASP.NET content management system for Developer Fusion…. write some articles in the process, plus squish a few bugs on the C#/VB.NET code converters!


Attended a great talk by Scott Guthrie a few weeks ago on ASP.NET 2.0 at the first Thames Valley User Group meeting – and bumped into him at the train station later on his way back to London. Very cool. At least, it was for me! ;,,) Now all I need to do is actually get a hold of the Whidbey beta…..

Thames Valley User Group Kick-off Meeting

Just thought I’d pass on the word about the first Thames Valley User Group meeting. It’s being held on 21st June at Microsoft Campus, Thames Valley Park (UK!). Speakers include Scott Guthrie (don’t think we need any introduction there…), and Andy Payne (technical architect at HP UK).

Membership and attendance are totally free. For the full agenda, check out http://www.thamesvalleyusergroup.net/agenda.aspx. I hope I’ll get the chance to meet some of you there! :,,)

“To avoid disappointment click on http://www.thamesvalleyusergroup.net/joinUs/joinUsForm.aspx now to enrol. Members can reserve a place at the inaugural event on the 21st June by emailing [email protected]. Please remember to supply your membership number with any request. Places are limited.”

Microsoft Error Messages

Apologies to everyone in advance – this just made me laugh.


There was once a young man who, in his youth, professed his desire to become a great writer.


When asked to define “great” he said, “I want to write stuff that the whole world will read, stuff that people will react to on a truly emotional level, stuff that will make them scream, cry, howl in pain and anger!”


He now works for Microsoft, writing error messages.

Automatically convert VB.NET code to C#

I’ve just launched another utility on Developer Fusion – this time, a converter from VB.NET to C#. This is the only VB.NET to C# converter that I’m aware of which is currently online.


The code is very much a work-in-progress. As with the C# to VB.NET converter, the code is based on the great work of the #develop team. I’m currently bug squishing (and these fixes will then be passed on to the #develop team too), so if you find any problems, please do let me know.