WinFX installation problem and fix for it

One day I've decided to install WinFX (along with VS 2005 beta 2) on my laptop to see how it works on hardware accelerated graphics (I take a look at WinFX before - in VMWare Workstation though). So I installed everything as requested. The first step to test it was to run XAML Pad, a utility to build UI using XAML. No go. I took a look at Fusion Log Viewer (fuslogvw) I saw that XamlPad application tried (unsuccessfully) to load totaly unrelated 3rd party assemblies built for .net 1.x (plus some of .net 1.0 system assemblies). Go figure. I haven't put much effort into solving this (who has time to play these days). I've rather posted a reply to a guy having same problem in MS newsgroup microsoft.public.windows.developer.winfx.avalon ("XamlPad.exe NullReferencException with WinFX CTP Sept." thread).

After a while, Daniel Danilin found (in another post in same thread) an (obvious) solution: remove offending 3rd party (not .net 1.x system ones) assemblies from GAC. While this solution isn't perfect (what about applications that use those assemblies?) it just works - and I have something to play with while traveling to my second MVP summit.

How to log DLinq's Sql commands

There was a question on MS' forum about how to log the DLinq's sql commands. Well, actually DataContext's sql commands. Here is the solution, it is easy:

StringBuilder sb = new StringBuilder();   // create a StringBuilder instance to store output
TextWriter tw = new StringWriter(sb);     // create a StringWriter that will write into StringBuilder above
db.Log = tw;                              // attach it to DataContext
Console.WriteLine(sb.ToString());         // output the result

The trick is to use DataContext.Log property (db represents DataContext instance in this example) to attach a valid TextWritter derived instance. And voila - no more black box. Of course, output will be empty unless there is a sql command issued either by doing query or persistence.

Dlinq and IChangeNotifier

I am doing some tests with DLinq. I have created my classes properly decorated with attributes. I have also implemented IChangeNotifier to make tracking faster (all this was created by my CodeSmith template which I will post later). However I couldn't persist a simple change which left me scratching my head for a while. Here is my pseudo code:

Load an entity
Change its property
Call DataContext.SubmitChanges

Simple, huh. Yet nothing was saved. I've checked with SqlProfiler to see if anything is going on - and no, there was no update command issued which indicated that DataContext was unaware of any change. At one point in time I've commented out IChangeNotifier implementation and the thing started working normally, as one would except. After another while I've found the problem - I was calling OnChanging() too late:

   set
   {
    if (value != id)
    {
     id = value;
     OnChanging();
    }
   }

Moving OnChanging one row up fixed the problem:

   set
   {
    if (value != id)
    {
     OnChanging();
     id = value;
    }
   }

This seems logical as OnChanging implies that is should occur before change is persisted. Another mystery solved.

The C# future

While C# 2.0 isn't even released yet, there is already a lot of documentation about C# 3.0. And it brings a lot of candies based on features introduced in C# 2.0 (generics, anonymous methods, ...). Go check it out. And go wonder, there is a also a working compiler (requires Visual Studio 2005 beta 2). I guess the fact that C# 3.0 works on .net 2.0 implies that it will come out much faster as there is no need to change the .net framework. I certainly hope so.

Visual Studio 2005 Team Suite RC available for download

Whoa, Visual Studio 2005 Team Suite Release Candidate is available for download at MSDN subscriber downloads. There is also a bunch of Sql Server 2005 September downloads. Apparently this is one and only RC before RTM.

Microsoft servers are under heavy load of course. I've barely managed to get to the link.
I wonder why :-)

An annoying bug in Visual Studio 2005 beta2 when using Developer Express' controls

A lot of people have noticed a highly annoying bug in Visual Studio 2005 when dealing with Developer Express' controls. The description of the bug goes like this:

During the build of the solution IDE starts throwing a modal dialog box with error icon: "cannot access a disposed object. Object name: 'DesignerFrame'". If you click OK the same dialog reappears and you'll never get rid of it (regardless if you click OK or not) and you won't be able to close IDE either (you have to resort to Task Manager for killing it). Regardless of the issue the solution starts running if it was built properly.

AFAIK this is the problem in Visual Studio 2005 Beta 2 and there are two workarounds to this problem:

  • upgrade to a CTP later then beta 2 (preferably july CTP since there is no public august CTP version of DevExpress controls) where error doesn't appear anymore
  • close all designer windows within IDE before doing build