Oct 10

apacheWhen developing all kind of projects a good strategy for logging can save you a lot of time and frustration. Personally I am very found of using Apache log4net and this post will describe the most important features in log4net and how to implement and use this in a .Net Compact Framework project.

log4net can be configured with different appenders that logs to different sources (file, output window, smtp, server ++). You can also configure what kind of log levels will be written to the different appenders (info, debug, warn, error and fatal).

Most of the time I use two different appenders: I use the DebugAppender to log to my output window in Visual Studio, I like to set this appender to log all levels. I also like to use a LogFileAppender to log to a file on the device, I usually set this appender to only log error and fatal.

You can read documentation and download Apache log4net at

Continue reading »

Tagged with:
Oct 02

NITHThis fall I will be teaching .Net mobile programming (.Net Compact Framework) at The Norwegian School of Information Technology (NITH) together with my good friend and colleague Alexander Viken.

We will hold a 3 hours session each week filled with lecturing, programming and discussions. I find it a great privilege to be able to talk about mobile development with the students and hopefully we will be able to motivate them with “real life” experience stories from projects we have been involved in.

We will cover subjects like:

  • GUI and usability
  • Error handling and debugging
  • Persisting data
  • Device interaction
  • Security
  • Communication
  • Deployment

Continue reading »

Tagged with:
Sep 30

Today I were developing a .Net CF application on a new laptop with every thing pre installed. Due to a third-party vendor I need to use Visual Studio 2005 for this project. When I tried to debug I got this message at my breakpoints: The breakpoint will not currently be hit. The specified module has not been loaded.

After checking debug settings and properties I managed to find out through google and a colleague that I need to install .NET Compact Framework 2.0 Service Pack 1 Patch. I installed the SP1 patch, restarted VS 2005, rebuilt my project and started it in debug mode. And like magic I were able to start debugging my project again :)

You can download the .NET Compact Framework 2.0 Service Pack 1 Patch from Microsoft Download Center.

Tagged with:
Sep 07

When developing mobile applications using Compact Framework and storing data to the local device database it is very handy to be able to debug and test sql queries direct on the device. This post will walk you through how to connect to the device DB, look at the tables in the device DB and run SQL queries on the device DB.

Run your application from Visual Studio, your device or emulator must be connected and cradled. (I’m running on Vista so I am using Windows Mobile Device Center).

You need to install Microsoft SQL server (I’m using the 2005 version) and run the Microsoft SQL server management studio.

Create a new connection with the following attributes: Continue reading »

Tagged with:
Jul 02

I have been involved developing a C#.Net Compact Framework project were we are using Model-View-Presenter(MVP) pattern for quite a while now and I would like to share my experiences learned during this project with you.

First of all, using MVP in a Compact Framework project is done exactly the same way as you would do it for standard C#.Net (or any other programming language). For some reason (unknown to me) developers tend to skip using patterns in mobility projects. I guess they think that good architecture is not necessary in smaller projects, like mobility projects often are. Wrong! As a developer you should strive to achieve good architecture in your projects no matter what size or complexity they have. What pattern to choose is of course another discussion. We chose to base the project architecture on the MVP-pattern and succeeded doing so. Let me walk you through how we ended up using it.

The figure below shows how the MVP components interact with each other. The View are implemented in the screens (forms) and the Presenter presents the data to be displayed to the View. The Presenter is responsible for the business logic and retrieve/save data to the Model. The Model will often interact with a Data Access layer (left out in this example for simplicity). The Model will also have business specific objects that both the Presenter and View can use, but the View will never ask the Model for data or save data to the Model.


Continue reading »

Tagged with:
May 05

A few days ago I wanted to create a fresher UI then what .NET Compact Framework offers out of the box. I wanted to create a gradient background for the screen and I wanted to have transparent labels on top of the background. In my opinion this is not much to ask for and I was a bit surprised that I actually had to do this myself.

Well after a few hours I made a gradient background and a transparent label. I will now step by step go through my solution.

The first thing I started with was to create a gradient background. I found that the best way achieving this would be to override OnPaintBackground in the Screen class. I found a very good article on how to do this on MSDN: How to display a gradient fill. I copied the GradientFill class and the Win32Helper class into my project, I didn’t bother using the GradientFilledButton class since I only needed gradient for my background.

Then I override the OnPaintBackground in my Screen, giving me this Form:

using System.Drawing;
using System.Windows.Forms;

Continue reading »

Tagged with:
Subscribe to my feeds Follow me on Twitter