maandag 28 september 2009

OCS Office Communicator Mobile R2 – Automatic sign-in

I recently purchased a Samsung Omnia Pro Mobile phone. This phone runs Windows Mobile 6.1. I like to stay in touch with colleague’s even when I’m not at the office, so I decided to install Office Communicator Mobile on my phone. The install was easy, and communicator works like a charm.

There was just one interesting issue I had: it seemed I could not log out of communicator. According to colleague’s (thanks Paul :-)) I was online all the time. Even when I closed the communicator task in Windows Mobile, I was online. (can you imagine my surprise when no apps were running according to Windows, but I was online) If I logged my self off in Communicator, it would be a couple of minutes before I appeared online again. (even though Communicator was not running!!!)

Looking around in the options of Communicator I found an interesting option with the label: “Automatically sign me in”. This was turned on for me, and I thought that this would log me on every time I turned on Communicator. This (of course) is not the case, because even if Communicator was not running I would be logged in. Since I turned this option off though, I have not had this thing happen to me anymore. So if anyone is experiencing the same thing, just turn this option off, and you will not be online anymore.

maandag 7 september 2009

C# – IRR Function

Today I was working on a financial application for a customer. One of the spec’s was an IRR (internal rate of return) calculation that had to be done. Since C# doesn’t offer any classes that can calculate the IRR, I decided to use the .Net Framework alternative: the IRR method from the Financial Class (in Microsoft.VisualBasic.dll). So one could call this method in the following way:

double IRRValue = Microsoft.VisualBasic.Financial.IRR(ref irrArray, estimate);

Unfortunately this will only work for simple IRR calculations. My customer has an array containing 16 cashflows. I have concluded that the abovementioned IRR method can only calculate arrays that don’t exceed 12 cashflows. If you exceed 12 cashflows the method throws an exception stating “Arguments Are Not Valid". (yes my friend, you are reading this correctly) Furthermore (yes, there is more), if you read the MSDN documentation on this beautiful method you will see that is says: “If IRR cannot find a result after 20 tries, it fails.”. For complex calculations chances are that 20 is to little, and thus you will get the aforementioned exception again.

Now you might be wondering how I solved this horrid issue… I simply used an open-source implementation of the IRR function. It is written in C#, and can be downloaded from this link. More info about this IRR implementation can be found on the official site. For me this worked like a charm.