Virtual member call in constructor with Datagrids

Although it has no obvious impact, I’ve had to repeatedly break the design guidelines rule of not calling virtual members in the constructor when working with subclassed datagrids.

public class MyDataGrid : DataGrid
{
 public MyDataGrid
 {
  ShowFooter = true;
 }
}

This throws up the warning Virtual member call in constructor.  To get around this, I’ve tried moving the call to the OnInit method:

public class MyDataGrid : DataGrid
{
 protected override void OnInit(System.EventArgs e)
 {
  base.OnInit(e);
  ShowFooter = true;
 }
}

This works and gets rid of the error, but removes the ability to change the ShowFooter setting from the datagrid tag on the aspx page (as when OnInit fires, it overwrites the value specified in the datagrid tag on the aspx page).

Maybe I’m missing something, but does anyone know a way around this (ie. setting datagrid properties programatically in a subclassed datagrid, without violating the virtual member call in constructor rule, whilst still allowing the setting to be changed from the datagrid tag on the aspx page) ?

Dreaming about the iPhone

About a week ago, my wife told me she came to wake me up, and I was rambling in my sleep about buying an iPhone and then throwing it away because it had too many features! Pretty weird… when she actually woke me up, I had no recollection of the whole thing.

Not just me having weird dreams about the iPhone.  Dare reports:

I dreamt I bought an iPhone. It was one of those dreams that seems so real you wake up thinking it happened. I finally realized it was a dream after I found my old phone plugged into its charger and not a brand new phone.

I’ve got no plans of getting one yet though.  Only recently dumped my SonyEricsson P910 for the T-Mobile Dash (which I love btw), and spending $500 for a new phone with a $60/month plan doesn’t seem worthwhile.

Also have to agree with Jeff Atwood, who explains why you don’t want an iPhone – yet.  Perhaps once V2 comes out and can reliably be unlocked and used with T-Mobile, I’d consider switching.

Still gotta try and make it to an AT&T or Apple store sometime though as I haven’t even played with one yet :-(

Tags:

Visual Studio 2005 macros stopped working

Grr, Visual Studio is behaving strangely again.  Yesterday, it froze for a little while, and since then, my macros have stopped working.  Aaargh, no more region tools!

I’m not the only one. There’s a few posts from other users experiencing the same thing in the past few days (one, two, three). I can only assume it’s a conflict between a new hotfix and other installed software.

After some Googling, I found Jim Shanks’ post, VS.NET macros stop working. Although the post refers to the 1.1 (VS2003) and I’m using 2.0 (VS2005), I figured I’d try it anyway.

The same info is also available under KB906763 on Microsoft’s support site, where they recommend doing a repair of the .net framework as the solution.

Trying to remove the .net framework throws up some error – something to do with other applications being dependent on it, so I can only repair the installation.  A couple of repairs later, and a couple of reboots, and things still aren’t working.

Also tried manually registering the dll using Regtlibv12.exe mscorlib.tlb, and that doesn’t work either, even though the dll registers successfully.

So for now, I’ve given up with this one.  By now, VS.NET should really include something built in for collapsing and expanding regions (rather than all outlining which I know can be done using the ctrl+m, ctrl+m, etc shortcuts).

If anyone has found a fix for this, please let me know.

Update: As JT says in the comments, rolling back the .net 2.0 security hotfix KB928365 fixes this problem.  More info here.