Ivan Mitev In The Software Trenches

Technology weblog on .NET development and other things that make the world go round

March 12, 2008

XmlWriter design flaws

I was very surprised to see an XmlException (hexadecimal value... is invalid character) when using a XmlReader on a XML file that was generated using a XmlTextWriter. It turned out that the method WriteString(String) does not check for some special characters and an invalid XML document might get generated. See details here.

The recommended workaround was subclassing XmlTextWriter and overriding WriteString() to handle this characters (remove or substitute the invalid characters). XmlTextWriter constructors accept parameters like Stream, TextWriter, but there is also a static factory method XmlWriter.Create(), which has overloads that accept an optional XmlWriterSettings parameter. The weird thing is that if no XmlWriterSettings is specified, then the Settings property of the XmlWriter is null and can not be instantiated, since it is readonly. This means that there is no way to create a subclass (e.g. SafeXmlTextWriter), with initialized Settings property. So, if the default settings are not applicable to your situation... well, tough luck, you can not apply the easy fix using the override:

public override void WriteString(String value)
{
value = FixInvalidCharacters(value);
base.WriteString(value);
}

January 01, 2008

Summary of the year 2007

2007 seems a rather quiet year in my career (at least blogging-wise). But it was quiet in a good way :)

It has been 1.5 years since I started working on Validata product and it continues to be mentally stimulating and fun. The diverse technologies in the project and the interesting problems keep me excited about my job. My company has joined a few projects in the Balkans, so the week before Christmas, I had my first business trip, ever. I went for Romania and next week I am going again.

I also have started a pet project that requires learning new stuff like ActiveRecord, Monorail, MySql, JQuery and other good stuff. I really hope to kick it off to a good start, while I am still on vacation. The more challenging thing is to make it a habit to have progress each day, no matter how little it is. I was somewhat unpleasantly surprised when I realized that it has been almost 3 months of inactivity from my last refining of the project idea. But now the project has stable foundations, there are no pending major technology decisions, so the work might just flow...

I have been keeping up with the new .NET stuff mostly from reading my daily doze of weblogs. I also attended a great seminar in Sofia in October, so the saw is still being sharpened :)

I have continued to refine my toolbox and programming techniques. I find that it's worth the temporary discomfort in learning how to use a new tool or technique.

I have a good feeling about the new year. And I will try to make this a self-fulfilling prophecy :)

Have a great new year!

October 02, 2007

DevReach 2007, Sofia, Bulgaria (Day 2)

Just a few quick notes about the session I visited in the Day 2 of DevReach.

Why Partial Rendering Is Not AJAX
by Dino Esposito, Level 300

Another excellent talk by Dino. I finally cleared some misconceptions in my head about AJAX, partial rendering, update panels and all this stuff. This was a practical talk that will help me a lot when I do AJAX again (the first attempt was a bit unsuccessful, but you know AJAX is not for the faint-hearted).

Silverlight, Flash on Steroids
by Lino Tadros, Level 200

An excellent talk, by an honest and humorous speaker. Lino's SL demo app was simple and well chosen. But Silverlight is still nor ready for prime time, since the tools are lacking and there are some basic controls missing etc.. (well, when 1.1 is ready, I might take a look at it again).

Being Smart About Database Design
by Vladi Tchalkov, Level 300

Very interesting talk about database design considerations: normalization, domain tables, keys, temporal tables, optimizations. One of the concepts I found very useful was one idea of how to implement temporal tables with a single table for the whole DB. One repeating thread in the talk was "know the rules so that you know how to break them properly".

RSS, Podcasting, and Syndication
by Carl Franklin, Level 200

A nice talk by the .NET Rocks host Carl Franklin. I learned about the Argotic .NET library. And Carl was very proud that his .NET rocks feed was valid, while the NY times was not (see FeedValidator) :)

LINQ - Deep Dive
by Branimir Giurov, Level 400

Branimir covered in detail all types of LINQ (for objects, datasets, SQL, Entities, XML). He showed the cool debugging support. Good stuff, looking forward to using LINQ.

A Busy Developer's Guide to Building Windows PowerShell Cmdlets
by Hristo Deshev, Level 200

My friend Hristo gave a very interesting talk about PowerShell Cmdlets (he is also writing a book on PowerShell, so he knows his stuff). Those Cmdlets are very fast to build and really powerful. I would like to play with them in case I have to do BAT commands or something more complex.

October 01, 2007

DevReach 2007, Sofia, Bulgaria (Day 1)

I missed the first DevReach in 2006, but this year I made it to the conference. All of the speakers on Day 1 were really good and they captivated me till the end of each of the sessions. Here is a quick recap of the talks, that I visited.

Side note: I don't know if it was just for the presentation, but none of the speakers that showed code in VS.NET had ReSharper installed. Just weird! :)

Developers are from Mars, Managers are from Venus
by Chad Hower, Level 200

I decided to start with a light and entertaining talk. I definitely got what I came for. Great slides, very humorous presentation... At one point in the presentation Chad asked his audience how many of us work for in a team of more than 10 people and only one guy (out of the fifty in the room) raised his hand. So, yes, there are very few projects that need heavyweight methodologies meant for building the software analog of aircrafts. Chad said that giving names such as lightweight vs heavyweight is not very fair, so he used the terms project-based and product-based methodologies (those were new ones for me).

Creating a billion dollar ERP system - case study of Velocity
by John Waters, Level 300

I didn't read the abstract of this talk and was a bit surprised (but in a pleasant way) that it was a very practical talk using a real code base. I finally understood what was the difference between ajax postbacks and ajax call. It was also useful to see how ajax works in practice, where does it make sense to use it and what is the cost of doing so.

Challenging ASP.NET/AJAX for Braveheart Developers
by Dino Esposito, Level 300

Again I didn't read the abstract carefully and was surprised that the talk was about: HTTP handlers and modules. But this was a very interesting topic that I knew very little about (only ELMAH sounds familiar). Dino gave his talk very passionately and went without hesitation 10 minutes in the coffee break. One cool thing he showed was a HttpModule, that I think it was called ASPExlorer). It got activated by appending a parameter in the querystring "source=true" and it made the HTTP response return useful information about the requested page: its assembly file path, its dependencies, its source code, etc... Pretty cool way for troubleshooting in production environment.

Scaling Habits of ASP.NET Applications
by Richard Campbell, Level 300

Richard (whom I have listened to a lot in .NET Rocks) was probably the most eloquent and artistic speaker. He definitely knew his stuff, too. His session was definitely useful since I was unaware about a lot of stuff concerning ASP.NET scalability and performance. One quote worth remembering: "Computers are amplifiers - they just amplify the developer's intelligence or stupidity!"

I am sure that the session in Day 2 will bring more good sessions (just like the ones today)...

July 06, 2007

Blindspot: 'hh' vs 'HH'

This is maddening! After working with .NET for more than 3 years, I just realized that I should be using HH (and not hh) to show 0-24 hours in a formatted DateTime. It is weird how I held this misconception for such a long time. If my workdays were from 00:00 to 12:00, then this could be justified, but that's definitely not the case...

Labels: