Neat Tip: Shortcut Keys VS.NET IDE

Jot it down. As the PP book said, it's important to know atleast one IDE very well.

  • Sometime back a 'fellow coder' asked me for a keyboard shortcut for moving to the next build error in the Visual Studio .NET 2003 IDE. Turns out it's as simple as F8. Now instead of moving to the task window and precision clicking on the next item in the list, Just press function key 8 and you are teleported to where you wanna be.
  • Another useful is one that takes you back and forth your function browse history. Lets say you click View definition from caller to be transported to callee. Now Press 'Ctrl & -' to simple waltz back to caller. (the reverse is 'Ctrl & Shift & -' ). No more remembering which file you come from and where you want to go.
For all the brickbats thrown, MS never ceases to amaze with some things of pure simplicity.

Resolving assembly references in a .NET solution

When Calvin proclaimed that "Life is a lot more fun if you are not responsible for your own actions", I think he missed this side of the coin where you don't know what the "heck" is going on..
I have a solution containing a "decidedly and dedicatedly rotten" project. This project references a 3rd Party component (v1.1) from a specific ExtLib directory. This directory is now embedded as the HintPath in the csproj file. Now the magic starts. I have a CI server (CCNet+ NAnt) running builds on the hour. This build machine has v1.0 and v1.1 of the component registered in the GAC. When I open the solution in the IDE, the rotten project gets the assembly from the GAC and the wrong one to boot (1.0).At runtime, it blows up saying that you do not have a license for 1.0. I have pleaded for a day that I don't want 1.0 take 1.1 it's right there you moron but no deal !

Things I found out today.

I don't know the assembly resolution process of Visual Studio. Here's my study notes though...

* When I add a reference to a project, it stores a relative path in the HintPath property (.csproj file). It then translates the relative path to an absolute path and stores it as a ReferencePath setting in the .csproj.user file.
* When I open the solution again, the IDE just picks up the assembly from the absolute path in the .csproj.user file.
* If I delete the .csproj.user file, the IDE seems to be getting the wrong version of the assembly from the GAC. This leads me to believe that the hintpath property is used only if the assembly is not found in the GAC. This time the .csproj.user file is not created, maybe because the reference was resolved from the GAC.

Now one way to resolve this was to add the ExtLib dir path to the ReferencePath property in Project Settings. This will create the .csproj.user file for you with the absolute path inside it. I don't check in .csproj.user files to SourceControl. So this is a workaround rather than a solution.

Another stunning piece of knowledge was on another machine, there is a dramatic difference. If I delete the .csproj.user file, I found that it automatically got the correct 1.1 DLL from the ExtLib (even though even that machine had 1.0 and 1.1 in the GAC) AND recreated the .csproj.user file automatically.


I'm a ignorant .NET programmer so HELP ME God !!

Ruby Sparkle: How to swap two numbers

Here's a perennial question how do you swap two numbers effectively ? Let's say a=5 and b=3 and you want to swap a and b so that a now holds 3 and b = 5.
So in the typical C way, common answer is use a temporary variable for swapping

temp = a
a = b
b = temp

Now for the stingy ones who don't wanna waste memory, here's another way

a = a + b;

b = a - b;
a = a - b;

If you are wondering what the hell have I been smoking, cover your eyes to keep you from being blinded by the brilliance of Ruby

a, b = b, a

This is like a gloved slap in the face. Touche !