Saturday, February 19, 2011


I would have thought the following was Visual Studio 101, but I’ve seen senior people confused by this, so I will elaborate.

If you’ve ever expanded the References section of a .NET Visual Studio project then you’ve seen the list of DLLs that your project can access.  Most of the items in a typical list are .NET Framework DLLs.  These are the Release build of DLLs, and they live in the GAC, or maybe somewhere in some Program Files directory if they are little extra packages, like the Silverlight Map Control.  Changing your project from Debug mode to Release mode doesn’t change the DLL link.  There’s only 1 available, the Release mode DLL from Microsoft or whoever.

Now, if you have a project in your solution that another project in your solution uses, (e.g. the business layer that your UI layer calls into) then there are at least 2 ways to add a reference.  One is a bad idea, and one is a good idea.  One way, the bad way, is the same as the references to framework DLLs – by referencing a particular DLL on disk.  The other way, the right way, is a project reference, which makes Visual Studio aware that project x depends on project y in the same solution.

If when adding a reference to another project in your solution you are using this tab then you’re doing it wrong:


See how you’re specifically selecting the debug version of a DLL in your project?  What will happen when you switch to Release mode and build your application?  It will include the debug version of this DLL, if it’s available on disk.  Not good.

The right way to set up a reference to another project in your solution is to use the next tab to the left, the Projects tab:


By using the Projects tab you get the following behaviour – when you switch your solution between Debug and Release build modes each project will use the corresponding build mode DLL from referenced projects.  That is, in Debug mode all Debug builds of referenced projects will be built and loaded.  In Release mode, all Release versions will be built and loaded.

There are a couple of ways of detecting references that were added using the Browse tab rather than the the Projects tab.  One way is to open .csproj files with a text editor and look for the following, which indicates a project reference:

<ProjectReference Include="..\DrinkLocatorMvvm.Data\DrinkLocatorMvvm.Data.csproj">

A non-project reference to a specific file will look like this:

<Reference Include="HtmlAgilityPack, Version=, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">

followed by a HintPath entry, which helps Visual Studio find the DLL on disk:


If you don’t like looking at .csproj files then a dead give away is the behaviour of reference paths when you switch from Debug to Release.  Put your solution in a particular mode, say Debug.  Right click on the reference in one project to a DLL that you know is in another project in your solution, select Properties and make a note of the Path.  For example:

C:\Users\jmclachl\Documents\Visual Studio 2010\Projects\DrinkLocatorMvvm\Lcbo.Model\bin\Debug\Lcbo.Model.dll

Now switch your solution into the other mode, say Release, and check the Path property of the same reference.  If it has changed to the corresponding DLL version, then you’re looking at a properly set up project reference.  For example:

C:\Users\jmclachl\Documents\Visual Studio 2010\Projects\DrinkLocatorMvvm\Lcbo.Model\obj\Release\Lcbo.Model.dll

If it doesn’t change then the reference was added as a file reference with the Browse tab.  Remove the reference and re-add it with the Projects tab.

Using file references, added with the Browse tab, may build fine in one mode, e.g. Debug.  But if you, or someone else who has checked out the project from source control, perform a Clean before a Release build the compile will fail.  That’s because the debug version of some project doesn’t exist on disk.  One very bad solution for this is to perform a Debug build before a Release build, but that will still add a debug version of a project DLL to your release build.  How slow do you want your app to run in production with debug code?  And do you really want to suggest performing a Debug build before a Release build to the folks maintaining your build server?  They should laugh at you.  If they don’t then your company has at least 2 problems – you and the build server person to whom you’re talking.

Understand the difference between a project reference and a file reference and you won’t end up with broken builds or the wrong build version of DLLs in your bin directories.

Sunday, February 13, 2011

Biggest Regret

I recently read an article about Donald Rumsfeld’s biggest regret (not pushing Jr. hard enough to accept his resignation after the Abu Ghraib abuses came to light), and it got me thinking about my biggest regret.

For many years my biggest and only regret was getting the arms on a leather jacket trimmed too short.  I liked to think that this was a nice only regret because it meant I didn’t regret any of my other life decisions, like the woman I married, the house and car we bought, having kids etc.

But I recently had to move a bunch of dishes and glasses given to us as  wedding presents.  It made me realize that my biggest regret was registering for wedding gifts. 

I appreciate the folks who came to the wedding and spent their money on us, but I regret not talking to more people about the whole idea of registering.  I’m sure I would have found out before it was too late that if you don’t register for gifts people will just give you money.  Register for a few gifts and they’ll give you a few gifts and a bunch of money.  Register for a lot of gifts and you’ll get a lot of gifts and a bit of money.   Get a lot of gifts and you’ll need to store a lot of gifts.  As a consequence I now just give money for weddings whether people have registered or not.

How this happened is, we went to the Bay and they handed us three things:

  1. A cardboard wheel on which you rotate a circle to the number of guests you plan to have and it tells you the number of table place settings and total dollar amount for which to register.  I seem to remember it suggesting 16 place settings.  I don’t remember the total dollar amount.
  2. A list of things that constitute a place setting.  From the gifts we received the list must have been:
    1. A soup bowl
    2. A salad plate
    3. A dinner plate
    4. A dessert plate
    5. A white wine glass
    6. A red wine glass (still can’t tell the difference)
    7. A martini glass
    8. A water tumbler
    9. A champagne flute
    10. A salad fork
    11. A dinner fork
    12. A knife
    13. A dinner spoon
    14. A tea spoon
  3. A bar code reader with which you run around the store scanning the things you want to add to your registry.  If you want 16 of something you don’t even need to scan it 16 times, you just enter ‘16’ on the scanner and scan once.

These are your “good” dishes, not your everyday ones.  This means you have to store it all somewhere separate from your everyday dishes.  Which is the situation we’ve found ourselves in.  What do we do with a dozen wine glasses, a dozen martini glasses and a dozen champagne flutes?  Store them.  Move them around the house, carefully.  Use them once every 6 months.  In short, manage them in a high cost, low benefit manner.

So, for Jebus sake, don’t register for much, or anything, for your wedding.

I’m only in my 30’s so maybe I haven’t lived long enough, or had a high powered enough career to have a significant biggest regret.   I certainly  haven’t been the CEO of a multiple companies, or defense secretary of the U.S., so I probably won’t have regrets on the level of Donald Rumsfeld.  (Seriously, how does he sleep?  On a pile of money surrounded by many beautiful ladies.)  But I hope to hold on to this current regret as long as possible.

Sunday, February 6, 2011

Better Bass On Your iPod

The iPod has an equalizer setting called Bass Boost.  However, for most modern songs this setting will cause a buzzy sound during bass-heavy sections.  As I understand it this is because most modern music is recorded very loud and the iPod doesn’t have the power to add the needed decibels.  One suggestion I read was to use iTunes to reduce the volume of all your modern music.  Rather time consuming.

The solution I’ve found is to go the other way – enable the Treble Reducer EQ setting and turn your music up.  This works best if you use headphones that produce really good bass.  I use and highly recommend the Klipsch Image S4 headphones.  With these headphones I’ve found the default sound setting has great bass but too much treble at higher volumes.  Reduce the treble and you’re golden.  The iPod doesn’t struggle to remove decibels.

(English is such a screwy language.  Every time I wrote the word bass I thought it was a type-o and that it looked like I was talking about fish.  We should standardize on “base” to mean low frequency sounds and the thing I’m in killin ur d00dz.  Leave the word that doesn’t end in e and has repeated consonants to be pronounced with a short and to refer to fish.)