Jump to page content

Bug of the moment 2007-07-20

Time for some catharsis.

There is a vague possibility that I might get to spend lots of time in the near future developing C♯ (AKA “C pound”) code. So, I put Visual C♯ 2005 Express Edition onto my desktop computer. As someone who’s spent years losing sanity to the REALbasic IDE, I was not sure what to expect of .NET and VC♯. It doesn’t have the absurd 1 GHz processor requirement of the new REALbasic, so it’s not intolerably slow, and not as fat as it could have been.

But oh boy, if you thought REALbasic made diabolical software, you are really in for a treat with Microsoft’s equivalent. This is the sort of package that instils genuine fear of using Microsoft software for a living.

Project vandalism

The most entertaining part of VC♯ is the way it vandalises your project randomly. Once was bad enough, and it did have the benefit of teaching me how forms were saved on disc, but more than once is taking the biscuit.

The annoying part is that I can never remember what button I pressed or what field I selected that triggered this phenomenon in each instance. I’m building a clone of HTTP Werkzeug in C♯, and I had just assigned icons to the request mode drop-down menu. (OK, not quite a clone, but I get cool graphical features to play with in Windows Forms that I didn’t have in REALbasic.)

Something odd happens to the form. I run the program, and notice that large parts of the window have simply disappeared:

The program is running, but the menu bar and both toolstrips are completely empty

A little odd, no? Of course, the IDE shows a different view, but the view after runtime (below) was not the same as it was before runtime, so even Visual Studio is confused.

My HEAD, GET and POST dropdown menu items have ended up on the next toolstrip down, and split out from their enclosing drop-down menu button (which has itself disappeared entirely). In cases like these, it’s hard if not impossible to repair the damage within the IDE so it’s time to open up the .cs files in JujuEdit. This was my lower toolstrip’s contents:

this.requestToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.refreshButton, this.redirectButton, this.requestModeDropdown, this.selectHEADrequest, this.selectGETrequest, this.selectPOSTrequest});

The requestModeDropdown had to be moved back into the toolstrip above, and the three mode menu items put back inside of it, like so:

this.locationToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.addressField, this.requestModeDropdown, this.goButton}); this.requestModeDropdown.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.selectHEADrequest, this.selectGETrequest, this.selectPOSTrequest});

Note that the dropdown requires DropDownItems.AddRange() instead of Items.AddRange(), because it would be uncharacteristically consistent to do otherwise.

In the previous case of this problem, all the menus on the menu bar simply disappeared from the IDE altogether.

Finally, fixed it (and with the Go button suitably decorated also):

The dropdown menu now contains the HEAD, GET and POST menu items

To the astute: no, I haven’t a clue why the menu bar didn’t draw in the first time. The menu bar itself was undamaged in this instance.

A spot of renaming

VC♯ is complaining about an image resource with a dot in the name

I imported the first three icons by simply dragging them into the appropriate Resources window. This triggered the names to be corrected. The final icon, I imported into the project resource file via the Select Resource dialog. While the icon worked, the IDE complained about the name. I am not sure how a working resource can have a broken name, but don’t ask me.

So I renamed it to what it should be.

VC♯ is using up most of my CPU time View full-size screenshot

Now what…? It’s locked up. Excellent. Notice the weird title bar buttons: Windows draws inconsistent and generally odd title bar buttons sometimes when a program freezes.

I gave it ages to sort itself out, but it seemed to be pretty much lost:

I must remember that, in future, you have to disassociate a resource before renaming it: VC♯ will not automatically update controls that make use of it. Not that I mind, but it would be cool if I learnt this without it crashing.

This entry brought to you by the letters C and ♯ and jx3p’s Leaving This Planet Mix.

Posted 20th July 2007 – Comments and questions?