Friday, October 29, 2004

"We are at war with Eurasia; we have always been at war with Eurasia"

In Orwell's 1984, a single all-powerful Party holds office, and maintains power via a novel form of propaganda - they change the past by amending archived copies of newspapers to ensure they comply with the Party's changing policies and stances.

"And if all others accepted the lie which the Party imposed—if all records told
the same tale—then the lie passed into history and became truth. 'Who controls
the past' ran the Party slogan, 'controls the future: who controls the present
controls the past.'"
Through the book, the "enemy" the Party are at war with changes several times, but the past is altered to make it appear as if the current enemy has always been the enemy. Thus: "We are at war with Eurasia; we have always been at war with Eurasia".

Why am I quoting from Orwell's 1984? When I first studied this novel, I remember thinking that no government or political party would ever be able to pull off something like that; it was just too audacious - it might be possible to change archived newspapers, delete old TV footage, etc, etc, but what about the people? No-one would be fooled by such a trick, surely? Not even Nazi Germany or Soviet Russia, both regimes that rewrote history to suit political ideology (for instance the Soviets edited state photographs to remove certain individuals who had fallen from favour), were able to sustain this. In the modern world, surely it would be impossible? There's just way too much media to control, including the internet.

Yet, last night while watching Question Time on the BBC I suddenly thought back to Orwell's book.

I've been becoming increasingly angered by the amount of deliberate news manipulation around the Iraq war, and increasingly angered that Tony Blair and his cabinet (with the exceptions of Robin Cook and Claire Short, who resigned over the affair) lied to us about the threat Iraq posed to justify the invasion. Don't get me wrong, Saddam was a nasty man, etc etc, but let's face it: the invasion was illegal, didn't have UN backing (and so due process was not followed), and has resulted in far more bloodshed and an active increase in the acts of terrorism in the world.

Now, what I saw on Question Time last night disturbed me; to paraphrase an exchange between Michael Moore and David Frum (former speech writer to Bush, and coined the term "axis of evil"):

Moore: "Saddam used to be our [i.e. the US] ally; he was our ally in the 80s; he was our ally when he was killing the Kurds, he was our ally when he gassed Iranian troops."

Frum: "This isn't Hollywood now; none of those things are facts."

Moore: "You're in front of a British audience now; they now their history. You can't say things like that!"

So, the neo conservatives in Washington would prefer the line that Saddam has always been an enemy of the free world, and that their former friendship with Saddam is just a Hollywood invention (remember also the "Arms to Iraq" affair, in which certain British cabinet members were implicated?). I don't know whether it's their sheer arrogance that annoys me the most, or the fact that some people will buy this rubbish.

I'll end this post with another quote from 1984:

"If the Party could thrust its hand into the past and say this or that even, it
never happened—that, surely, was more terrifying than mere torture and death."

Tuesday, October 26, 2004

Datasets

I mentioned my dislike of Datasets in a previous post, which prompted an "anonymous" post (I know who you are!) asking a rhetorical question about the virtues of custom collections. Well, it may have been a rhetorical question, but I answered it anyway. Go see.

Tuesday, October 19, 2004

Edit & Continue in C#

Rumours are that edit & continue will be available in C# in VS 2005 after all - it was originally touted as returning to VB.NET, but wouldn't be available in C# due to time constraints. Glad to see that this is no longer the case; it also makes a lot of sense, as edit & continue is a feature of the dev env and debugger, not the language.

Note that ASP.NET will not have edit and continue enabled, apparently because to do so was considered too technically challenging given the release schedule for VS 2005.

Friday, October 15, 2004

Debugging Deserialization Exceptions

I hit a snag recently while using web services hosted under Websphere in a c# client. I was getting an invalid format exception when invoking the web service; the service's author had no idea what the problem was; it generated valid WSDL, and the problem occurred at runtime. The XML looked OK.

So how do you go about debugging the deserialization process at runtime?

The serializer creates source code at runtime and compiles it into a randonly-named assembly, before deleting the source. It's possible to keep that source code, and debug into it.

1. Put the following in your config file:

<system.diagnostics>
<switches>
<add name="XmlSerialization.Compilation" value="4" />
</switches>
</system.diagnostics>

This will force the serializer to leave the source code lying around, rather than deleting it.

2. Keep your eye on the output window as you launch your app; you're looking for an oddly named assembly being loaded, such as 7dr9bhsr.dll; this is the assembly generated by the deserializer at runtime, and it's name will change every time your app is run;

3. Look in your temp folder (C:\Documents and Settings\\Local Settings\Temp) for a .cs file that matches this weird dll name;

4. dbl-click on the .cs file to open it in VS;

5. Under Debug Exceptions, make sure you are breaking into the debugger when the exception is thrown;

6. Run your app to recreate the problem that causes your exception;

7. The debugger will break on the line in fault in the source code file;

You can then step through the code, and work out exactly what is failing to be deserialized...

Binary Serialization of Datasets - Problems Solved in .NET 2

If you've ever used ADO.net Datasets to pass large amounts of data around via Remoting, you've probably hit the performance problem described in this article. The problem arises because the binary serialization of datasets is hugely inefficient, and results in bloated data payloads being passed between your servers.

Most people use datasets because it's easy to get up and running with them; I don't like them, precisely because they're bloated and inefficient (in .net 1.x at least), and because they're not truly object oriented: custom collections (inherit from CollectionBase or ReadOnlyCollectionBase) of objects are easy to implement, efficiently serialized (and so faster over the wire), and are much more elegant.

That said, MS have improved the performance of the binary serializer in .net 2.0, and it looks like there's quite a performance improvement over previous versions.