Rory Primrose

Learn from my mistakes, you don't have time to make them yourself

View project on GitHub

Is your timer not firing?

I have been developing an RSS aggregator for a while now because I am not happy with any of the apps around. My little project has also meant that I get really good experience developing in VS2005 and SQL2005.

I made a change late last week that the timer used to check for pending feeds was set up to run at the end of a call that loads the user and feed information from the database. The change I made was to have that method run on a different thread so that the UI wasn’t tied up waiting for the database that it may or may not be able to connect to. Today, I am noticing that my timer just isn’t firing.

I was thinking that the only thing that has changed with regard to the timer is that it is now getting initialised and started from a thread that is not the GUI thread. Why should this matter? Perhaps I am showing a little bit of ignorance here, but it shouldn’t matter.

Read More

Unpredictable control rendering is never a good thing

Probably the things I struggle with most in the IT industry (and usually when looking for a new job) revolve around the questions of:

  • How good am I?
  • How much do I know?

These questions are really hard for anyone answer although having a degree and/or other certification helps to indicate what you should know.

Following from these questions, I have often thought about whether I would be good enough to work for this company or that company. Take Microsoft for example. Would I be good enough for them? I don’t know, but I like to think that they are the benchmark for a programmer’s skill as they are a leader in the industry. Every now and then though, I come across some Microsoft code where I can’t really understand why they developed something the way they did. This time, I have come across how checkboxes and radio buttons render themselves in ASP.Net 2.0. I would like to know whether there was some kind of valid design reason for the rendering behavior of these controls or whether it is just, in my humble opinion, poor design.

Read More

Development Tools

These are the development tools that I use. I will skip the obvious applications (which are typically the ones you pay for).

Applications:

  • Reflector - Assembly browser and de-compiler for .NET components
  • NDoc - Creates help documentation from XML comments
  • Dependency Walker - Finds dependencies (great for non .Net app development)
  • Process Explorer - Process management utility
  • Resource Hacker - Great for modifying existing dll resources
  • SQL Scripter - Generates scripts of an existing SQL Server database
  • NSIS - Scriptable installer

Addins:

Sites:

  • PInvoke.Net - Converting API calls to managed methods
Read More

Tricky paging - Learning something new everyday

My team lead sent us an email with a link to http://smh.com.au/articles/2005/11/02/1130823242025.html. He stumbled across a cool bit of functionality when he copied the contents of this five page article. He found that if you select the entire page, copy it to the clipboard then paste it into a program (like notepad), then all five pages of the article are pasted into the document (although this doesn’t seem to work when pasting into Word though).

How does this work?

Firstly, the contents of all five pages are in the source code for each page downloaded. The contents for each page is surrounded in a DIV that has a class and an ID that identifies the page number. There is a script in the page that looks for a querystring that indicates the page number. It loops through each page content DIV and shows or hides it as appropriate. There is a stylesheet reference in the page defined as media=”print” that includes a reference to the css class. This class ensures that when the document is printed, all the page content DIVs are rendered.

So that covers displaying the correct page in the browser, and also printing all pages. What about copying it to the clipboard?

I originally thought that a copy operation was using the media=”print” stylesheet. With a little testing, it seems that this is not the case. A copy seems to ignore the display style and goes off the HTML defined instead. In the case of this page, a copy has the same effect as the media=”print” stylesheet in that all page content DIVs are included.

Whether the copy behavior was understood by the developers or not, it is a very cool side-effect.

Read More

Opinionated or Passionate?

There are several things that I mark up as me being passionate about. From a technical point of view, these include coding, OOP, .Net, VB, great looking UI, controls, smart clients and so on and so forth (always wanted to say that but it is a bit long, should now be referred to as ASOASF).

Outside of these things that I am passionate about, there are several things that I have always considered as me being opinionated about. Coming up with the best design for something, be it an application, component or a control is probably the one that sticks out most and tends to get me into the most disagreements in the workplace. I can’t stand poor design (even though I probably come up with enough of them myself). I am often discussing/fighting for the best design with other people, regardless of whether they are workmates or my managers. It doesn’t matter to me. I think it is more important to do a good job and get the most appropriate design than be a ‘yes’ man. I will explain my position and argue the point until I a) get what I want; b) get an acceptable compromise or c) someone pulls rank and outbids me.

The point here is that because I put my opinion out there, I considered myself opinionated. I saw it in a negative light. I guess this was because I was disagreeing with other people’s ideas. That is until yesterday.

I was discussing some issues with the lead of a build team and someone else at work. I was giving one of my opinions and I tried to ease the opinion into the discussion by saying ‘…., but I am just opinionated’. The build team lead corrected me by saying that I was passionate, not opinionated. I thought about this for a second. It’s true. I haven’t been opinionated for these last six or seven years in the industry. I have been passionate. I want the best results.

The other guy in the conversation replied with ‘in your opinion…’

Read More

It's all about customer service

What picks one business from another?

Especially after there has been some history of customer interaction involved, it comes down to customer service. In this latest edition of ‘Who wants my business’, I have had to deal with Sunglass Hut and Oakley.

My wife bought me a pair of eye jacket Oakley’s about seven years ago for my birthday (you get to choose which one). They cost about $160 at the time and have been worth every cent. They have however finally come to the end of their days. The frame must have just become too brittle in its long life and the frame broke above one of the lenses.

Read More

Getting nested ASP.Net control designers to render

Last week, I posted about how nested control designers in ASP.Net were not rendering. I have progressed a lot in the last week regarding getting good support for controls in the designer. No doubt some articles will follow.

With regard to nested designers getting called, this will only happen when the control related to the designer is hosted in an editable region.

The page for example is the classic editable region. You can drag and drop controls onto the page. You can select the control and change its properties through the property grid. Controls themselves may also have editable regions if their designer has been developed to support them.

Read More

Publishing embedded resources in ASP.Net 2.0

I put up a post a while back about my issues with publishing embedded resources from an assembly with ASP.Net 2.0. Ramon wanted a sample, so here it is.

There are a couple of things to note about getting this to work:

  1. The resource must be marked as Build Action = Embedded Resource
  2. Line 18 in ResTest\ResTestLib\My Project\AssemblyInfo.vb must include the full namespace of the assembly, not just the filename of the embedded resource
  3. As above, Line 21 in ResTest\ResTestLib\ResTestControl.vb must also include the full namespace of the assemlby, not just the filename of the embedded resource
Read More

Nested Whidbey ASP.Net control designers

I have been designing and building a nested set of web controls over the last couple of weeks. By nested, I mean that there is a parent control that contains a set of child controls of a specific type.

I like to have default behaviours of my web controls in the designer when they are empty. For example, the parent control would add 3 child controls if it was empty and the child control would display something if it was empty, like how the label displays “[ID]” when the text property is empty.

One thing that surprised me was that the designers for the child control don’t get called when rendering the parent control in the designer. This means that the behaviour of the parent’s designer must also do the designer work of the child control.

I am sure this is not right. One of the reasons I think I am missing something here is that if I take the panel control (which has a designer), and I put my own control in it that has a designer, my controls designer gets called. Why would it be different with two of my own nested controls?

I hope I am missing something because the nested controls should be calling their own designers to help with design-time rendering rather than relying on parent controls which would typically be completely unrelated (the panel isn’t going to understand how to handle an empty label control).

I will have to check my code again.

Read More

Generally speaking, name collisions are bad

I have been developing some Whidbey web custom controls for the last couple of days. I have been getting a little frustrated with what looked like (and probably still is) bugs in the designer.

I have been creating a custom tabbar control. Let’s call it MyNamespace.Tabbar. I have designers, builders and converters to improve the designer support. Most of the time, the designer support just doesn’t work. Sometimes I get a great error saying that MyNamespace.Tabbar can’t be converted to MyNamespace.Tabbar. Given that both the assembly’s namespace and System.Web.UI are imported, I probably have a naming collision on the control.

Parts of the framework are still able to determine that I am referring to my Tabbar class rather than the System.Web.UI.WebControls.Tabbar (given the error message rendered in the designer), but elsewhere, it can’t follow through (hence the error). BTW, at runtime, none of this is a problem. Interestingly, even when I clarified the declaration with the full namespace, it still fell over in the same spots in the designer.

After a name change, it is all fine.

Read More