Bootcamp 3.1 installation error, KeyAgent could not be started…

I am running Mac OS Leopard on my Macbook Pro. Using Bootcamp I run Windows Vista 32bit too (I am ashamed of that). Lately I have been seeing some weird behavior with my Windows side. the screen just freakin freezes, the only option is to hold the power button down and restart, Ouch!! After reading few blogs I kind of realized that this might be an issue with the NVidia graphics card and Bootcamp drivers.

So I got the latest Mac OSX Snow Leopard CD. The installation could not be smoother than that. Absolutely stunning. Booted the Windows side, started installing the new Bootcamp 3.1. It upgraded several new drivers for NVidia, ATI, Intel …. And almost at the end, booom! Service “KeyAgent” could not be started. Of course nothing is straight with Windows I said. So I used the most powerful command know to a Windows user, RESTART. I restarted twice to get the same error.

Then I realized Vista being a really clumsy OS, there is something annoying in it called the User Account Control. I keep it off all the times. So I turned it on, restared again, and this time guess what, the installation worked. It seems that the installer is trying to modify some bits which the UAC was not allowing. Not sure though.

Try this if you are stuck with this error. Honestly a better option would be to get Windows 7 or atleast upgrade to XP.

Searching for the Response Header property in MessageSecurityException?

I had a requirement in my code wherein I had to make a webservice call, catch a HTTP 401 exception returned by the service, read a value from the header, add some value in the header and call the service again. Seems not very uncommon to me. My client was a WCF application and service was written in Java. Apparently, the exception that was being thrown on client side was of type System.ServiceModel.Security.MessageSecurityException. I remember I tried for about half an hour to find where the hell is the Response object returned from the server. Here it is,

try
{
Webservice Call..
}
catch (MessageSecurityException ex)
{
if (ex.InnerException != null && ex.InnerException is WebException)
{
WebException webException = ex.InnerException as WebException;
string sample = webException.Response.Headers["Sample"];
}
}


Happy Programming!

No one likes their code to be changed

I consider myself really really lucky to be in the business of writing software. The reason being, this is the only creative thing I do in a day. When I am done coding a module, I am like, look at this thing, its my work :). ( It might not follow all the SOLID principles, but… well.. what the heck!). And I bet every programmer on this planet has some kind of love with the code they have written in an editor. When someone comes along and without taking your “feelings” into consideration just tears apart the code to “refactor” it, or may be remove extra white spaces for performance reasons!, you can be certain that the person is going to get pissed off at this. Be it your best friend, girl friend whatever, if you think a piece of code is not written with good standards, it is wise to explain why its not good to have it like this, and then delegate that person to refactor or take it up yourself in a friendly way.

Taking someone’s code, refactoring it and checking in with an email saying that your code was not good enough so I refactored it, will only suck all the spirit out of that person and you would be basically named as a dick in the team.

Happy Refactoring!

So you want to use Continuous Integration!

Alright, this would be among the better decisions you would have taken in your project. Good for ya. Well… what next? This is what happened to me lately. Whenever a new thing comes in town, like a pragmatic programmer I do not get on the “Wow this is awesome” wagon until I have done some homework over it. So for Continuous Integration (hereafter mentioned as CI), I looked around the cloud and found several options. One option that is obvious was CruiseControl. It has been used for quite some time in the developer community both .NET and in Java (and others may be). Not sure if it is just me on this, but I found configuring and getting in running for my project became a project in itself. I was basically sitting in front of my laptop trying to get my local svn server, CruiseControl  and few other bells and whistles that come with it to try talk to each other. Not straightforward.

Now you can certainly argue like, Ohhh commmmon man, you are a developer and nothing is straight forward anyways, CruiseControl is configurable in just a snap by editing xml files here and there, starting the service etc. But really I feel things like CI, Source Control which are used to enhance the efficiency of a team, should not become a management task in itself. It should just be easy to setup and get going. And so there is a relatively new kid in town Hudson. It is written in Java by Kohsuke Kawaguchi of Sun. I believe its only his brain into this tool and that makes it consistent throughout. I am mainly .NET guy and needed to get my C# projects into hudson. So here is what I had to do to get Hudson talk to my other companions on my laptop –:

  1. If you are completely Java agnostic, and happen to have no trace of Java on your machine, you would have to download Java atleast version 1.5. Get it from here, http://java.com/en/
  2. Download the latest and greatest hudson.war file from http://hudson-ci.org/latest/hudson.war.
  3. Place the downloaded hudson.war file at some sensible place, well I have it here C:\Hudson.
  4. Open a command prompt and get to folder location which has the hudson.war file. Issue the following command, java –jar hudson.war .
  5. Once hudson is started, visit http://localhost:8080/ on your browser and voila, you should have a wonderful Hudson dashboard smiling at you.

Now to configure my .NET project,

  1. Click ManageHudson in the left navigation links on the Dashboard. Click Manage Plugins (3rd link for the lazy ones, man I am spoiling you). Click the Available tab, Select the MSBuild Plugin and click Install and the very bottom of the page.
  2. Hudson would download everything you ask for and the automatic updates right off the web interface, so no need to upgrade manually.
  3. The MSBuild plugin is basically used to well, build your .NET projects using msbuild.exe. Configure this plugin with your msbuild settings. For really basic settings, Click Manage Hudson again. Click Configure System, navigate to MSBuild Builder section, name it something like MSBuild .NET 3.5 (can be anything really) and the path to the msbuild.exe. Typically the path would be C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe. Hit Save the very bottom of the page.
  4. Now go to the home page, click New Job. Give some Job name. Select “Build a free-style software project” which makes it all configurable.
  5. Since I use Subversion, in the Source Code Management section, I selected Subversion, and gave the repo url as my local repository path(svn://localhost/myproject/trunk/ConsoleApplication8). Local module directory can be set to a period “.”, so that Hudson copies the code files directly into its workspace.
  6. In Build section, click Add Build Step. You should see the Msbuild name you gave in the MSBuild plugin setup. Select that, for the MsBuild file, give the name of your solution like so, ConsoleApplication8.sln. You could give any additional command like arguments to MSBuild if needed for your project.
  7. Hit Save. On the Home Page you would see a link to your project. Click that, you should see a Build Now link in the left navigation links. This would build your project. Wohoooo!!

This is just a basic setting I did in Hudson and got myself CI’ed with Hudson. There are several options to choose from if you know what you are doing of course. I am still overhauling this tool and no doubt it sounds promising. Here are few wonderful links for much deeper help,

http://blog.bobcravens.com/2010/03/01/GettingStartedWithCIUsingHudsonForYourNETProjects.aspx

http://redsolo.blogspot.com/2008/04/guide-to-building-net-projects-using.html

Happy Integrating.