Config file behaviour MonoDevelop and Visual Studio

February 25th, 2010

Updated Mono and MonoDevelop to their latest version and I’m pleasantly suprised. Ran all unit tests of my channel library and they all passed with flying colours, that means there have been some serious WCF improvements.

The only small difference in behaviour I’ve noticed so far is that config files are not automatically copied to the output directory. In order to do this, right click the file go to “Quick Properties” and select “Copy To Output Directory”.

And another thing, “Add Reference” in MonoDevelop is pure bliss. Look at that speed Microsoft!

NoXML Spring.NET

February 14th, 2010

If you say to any .NET programmer you use Spring.NET (that they know it exists is already good to hear) the discussion will head immediately into XML world. Yes they can be a pain but with a bit of discipline you can keep them structured and well maintained, though if I could choose I’d drop them too. The reason I’m still sticking to this framework is because it offers so much. DI, AoP, data access, messaging,… most applications I’ve created need at least some components from the Spring.NET stack.

Erich Eichinger has posted on CodeConfig and assembly scanning for Spring.NET a while ago and it is scheduled to be included in Spring.NET in the future. Go check it out.

Reading PDF files on the iPhone

February 14th, 2010

You can natively read PDF files with your iPhone yet one feature that is lacking is a go to page feature. This is not an issue when you have a file which is only 2-3 pages long, typical size of a file being send through mail. But when you want to get some serious reading done and have already read a couple of hundred pages in the book, having to skip through all of them when you want to continue where you left off becomes a serious issue fast.

There are a lot of options when you look for pdf or ebook reader in the App Store some are payware some are free. I was very reluctant to get one in the past, hoping that Apple, in its infinite wisdom, would add the feature to the standard PDF reader.

Yet as of this date it’s still not implemented.

A friend suggested I check out Aji Reader, it’s free at the moment and I’ve used it for several months. I’m quite happy with it. You can get content on your phone with a desktop application that syncs your pdf files.

With the iPad around the corner I’ll probably read less on the tiny iPhone screen and move to this new platform but this blog post has been in my todo list for far too long.

Fluent Spring.NET configuration with Recoil

October 14th, 2009

This is so important I had to blog about it immediately, have not looked at it yet but I’m excited! Someone was kind enough to kick-start a project to enable Spring.NET configuration via a fluent interface. Perhaps no more xml in the future. Read all about it on the author’s website and on the Spring.NET forum.

Using SQLite in 64-bit .NET environments

October 12th, 2009

When you download the binaries from the SQLite site you’ll notice that there are specific versions for different environments. While I used the 32 bit version on my Vista 64-bit machine in the past, or at least I think I did, I ran into problems with them when I migrated to Windows 7.

Turns out that some code in the 32-bit library can’t run on a 64-bit version for reasons that probably matter but are unknown to me.

.NET applications run natively in 32 or 64-bit mode depending on your system by default, if you keep your compile settings unchanged. The only way to use 32-bit libraries, that have specific 32-bit dependencies, is to change your compile settings or use a tool that ships with Visual Studio / the SDK.(CoreFlags.exe)

To change your compile settings in Visual Studio:

  1. Go to the startup project of your program.
  2. Open the properties window.
  3. Click the compile tab.
  4. Click advanced compile options.
  5. Change the target CPU options to x86.

Your program will now always run in 32 bit mode, even when run on a 64 bit machine.

You could also provide two distributions, one for each environment. While this will become the standard in the future, for my current project this was the best and easiest option.

More info can be found here: Running .NET Apps in 32-bit mode on 64-bit Windows, MSDN: 64-bit Applications, Visual Studio Development Environment 64-Bit Support, forum post at the SQLite site

October 2009 bookshelf

October 11th, 2009

Sams Teach Yourself WPF in 24 Hours

I’m in the process of creating an application for a friend of mine who is starting his own company. He needs a little CMS system to support his business in the advertising world. He gave me a nice layout to use in the application so WPF seemed to be the best option. I jumped right in only to find that it was more complex than I first expected. After looking around what was available I decided to go for this book since it’s co-authored by Rob Eisenberg who is in charge of the Caliburn framework.

I’m just passed the first part of the book which introduces the layout containers (grid, stackpanel, wrappanel,…) and the basic containers. It already helped me getting the layout right for the application I’m writing. Also the code snippets in the book are in colour which certainly improves the readability of especially the XAML.

The Art of Unit Testing: with Examples in .NET

Though I’m convinced of TDD and unit testing in general I find it hard to apply when doing projects at work. I’m hoping this book will help me to structure my programming work around TDD and how to write good maintainable tests. The text is written in an easy to read manner and currently feels like a step by step guide on how to become a better test writer. You don’t need any prior knowledge to get started with this book. I’ve only read the first 100 pages but in my eyes it’s already a classic, go get it.

Dependecy Injection in .NET

Earlier this week you could get this one for a mere $10 via a twitter promo code. Though I’m fairly confident I know what DI is, when to use it and what the advantages are you always need to keep an eye out for any new insights or information. Have only read the first couple of pages where the problem of coupling between your components is sketched. The book is still a work in progress, but you can already get it via the Early Access Program.

WCF ChannelManagement bug fix

July 24th, 2009

Not really a release but I’ve just applied a bug fix that solves a null reference exception when returning null from the service you’re calling. Thanks to Jay from the Spring.NET forum for reporting and fixing the issue. I’ll clean up the code and add some more test cases the coming days. The updated code is available in the svn repository.

Memory profiling from the trenches

July 23rd, 2009

When you’re in school you learn that the .NET framework takes care of all that nasty memory management. From the moment you’re past all those small exercises and develop “real” software you quickly see that if you don’t follow some guidelines the garbage collector fails to reclaim memory.

The past week I’ve spent quite some time using ANTS Memory Profiler to look for leaks in a big project at work. It’s a Windows forms application which talks to online webservices. It was pretty clear from the start that any form that was opened remained in memory since the total memory footprint increased and never dropped. Using ANTS you can easily see how much instances of which class are active, how they are related and how much space they occupy. Rather fast I found that a lot of eventhandlers were keeping hold of the forms or presenters (we use MVC to create our UI) hence the memory footprint.

It’s a good practice that whenever you subscribe to an event, you also unsubscribe when you no longer need to know about it. Every += needs its -=. In some places its easy to spot. When you got one presenter, let’s see an OrderPresenter with one view, OrdersView, you quickly see the mistake that was made. But in more complex situations, let’s say that OrdersPresenter was also talking to an CustomerPresenter and OrderDetailPresenter which in turn talked to other presenters you’ll be switching between Visual Studio and ANTS to try to understand what’s going on in the system.

Never the less, I was able to get all the forms disposed properly when they were closed or no longer needed. Except in one specific situation. The application has a multiple document interface (MDI). When it starts it loads the OrdersOverview form and shows some global information, in this example all current orders. When I closed this overview screen and looked at the output from Ants the form was still in memory. No matter what I tried, for some reason the MDI parent kept referring to the MDI child which was closed. After hours of walking through the code to find the culprit I launched one Google query which found a page on Microsoft Connect. It’s a bug in the .NET framework, sigh, what a waste of time.

Another thing that was new to me was that whenever you show a form as modal and you close it. It will be kept active as well, you need to explicitly call Dispose to get rid of it. Four years of WinForm development and I still learn so much new stuff.

SVN Repository available

July 23rd, 2009

I’ve made availble a svn repository with the source code of the channel library for Spring.Net and my work on a Cuyahoga module for events. The last one is still pretty much a work in progress. I think I’ll be able to work on it some more later this year. There’s a lot on my todo list.

Readers have reported that the latest version of Fluent NHibernate breaks the approach which I illustrated on this blog, I’ll look into that later today. I’ll also be patching the channel library with a bug fix which someone on the Spring.Net forum was kind enough to provide. Had hoped to do that yesterday but the machine on which I was working did not have NUnit installed and Sourceforge was down. So stay tuned, this blog will get some more action in August.

Repository is located at:

This week on my screen #10

June 14th, 2009

Number 10 already.