Monday, September 25, 2006 - Posts

Moving from .NET 3.0 Beta 2 to RC1

I finally got around to this yesterday (at least on my work tablet - my home PC will have to wait until I have some more bandwidth available so I can download the Office 2007 Beta 2 Refresh...the joy of monthly caps. I've completely given up on keeping the Windows SDK up to date for now - the version I'm using shoud be sitting in a rocking chair surrounded by photos of its grandchildren).

Yes I know there have been CTPs (I lost track of how many) between Beta 2 and RC1, but I've been suffering from CTP exhaustion (and the aforementioned bandwidth caps are also a bit off-putting).

As I mentioned in an earlier post I've been working on a WPF client for  searching Amazon.com...partly because Amazon provide some of the few truly useful public web services, and partly because this was close to a real-world programming problem that would hopefully enable me to learn how to do something useful with WPF (as opposed to Yet Another RSS Reader For Only One Feed That Never Updates).

But anyway, I wanted to talk about my upgade experience.
I had known in advance of a few breaking changes and incorporated them into my code, and I obviously expected to have to update my references.
I still got caught by a couple of things however.

Initially I was getting what appeared to be bizarre interop errors, accompanied by an "Access is denied" exception, which had me taken aback. This was fixed by - wait for it - adding a Title attribute to my window. Just goes to show.

Then I noticed that my default TextBox was no longer receiving focus on startup...that had me puzzled for a while, because the expression I use
( FocusManager.FocusedElement="{Binding ElementName=searchBox}" ) agreed with the syntax in recent examples. I checked that my TextBox was indeed called searchBox (we can debate whether it should be, but frankly Scarlet I don't give a damn). It was. Then I realised that unlike everybody else, I had my FocusManager settings thingy bit defined at the Window level, a couple of levels above searchBox. This worked fine in Beta 2, but clearly things are now different. I move it to the containing element of searchBox and it worked like a charm. I don't remember seeing that listed anywhere as a breaking change, but I might have just missed it while ignoring updates, or it could simply be that nobody mentioned it because they didn't expect anybody to do anything stupid like defining it at the top level anyway.

So now it works fine, which is nice.
It's great to finally be able to try out WPF in its feature-and-syntax final form. The possibilities are many and nifty.

Update: Yes I know that .NET 3.0 Beta 2 is arguably an anachronism, since it was still called WinFX back then. But it's nowhere near as bad as when I was studying 6th form history and forgot when the Austrian Empire became the Austro-Hungarian Empire. So there.