Tired of looking for errors in log files? Use OneTrueError - Automatic exception management for .NET.

Introducing OneTrueError.com

OneTrueError.com is my new startup for .NET developers. It’s a bit like ELMAH, but for most of Microsoft’s different frameworks, and with a tad bit of analytics.

Continue reading

Posted in CodeProject, OneTrueError | Tagged | Leave a comment

Alternative to IEnumerable for read-only collections

.NET 4.5 introduced a new interface which is great if you want to expose a collection as readonly.

The problem with IEnumerable<T> is that it’s forward only. i.e. there is no guarantee that you can traverse it multiple times. The collection size might also be unknown, depending on the implementation.

So if you want to expose a collection which can be traversed multiple times and where the size is know there is as of .NET 4.5 another alternative. And that’s IReadOnlyList<T>. It inherits another new interface called IReadOnlyCollection<out T>.


public interface IReadOnlyCollection<out T> 
      : IEnumerable<T>, 
    int Count { get; }
public interface IReadOnlyList<out T> 
      : IReadOnlyCollection<T>
      , IEnumerable<T>
      , IEnumerable
    T this[int index] { get; }

Usage example

public class MyRepository
    public IReadOnlyList<User> FindUsers(string lastName)
        // [...]

    // [...]
Posted in Architecture, CodeProject | 1 Comment

Immutable collections should not implement mutable interfaces

I just read the new blog post about .NETs new mutable collections. It mostly looks really nice, but there is a major problem: They implement mutable interfaces like IList<T> which has an Add() method.

Continue reading

Posted in Architecture, CodeProject | Tagged | 16 Comments

A better windows service helper

I’ve updated my windows service helper so that it also can install your service for you (through the command line).

Continue reading

Posted in Uncategorized | Tagged | 1 Comment

Throwing exceptions

Throwing exceptions is in itself trivial. Just invoke throw with an exception object. But when should you throw? Should you create a new exception or rethrow an old one? What should you include in the exception info?

Continue reading

Posted in Architecture, CodeProject | Tagged | 3 Comments

If you can’t explain it simply, you don’t understand it well enough


Posted in Uncategorized | Leave a comment

How to design exceptions

This article will teach you how you should design your exception classes. It’s a follow up to my previous article which told you what exceptions are and their intended usage.

Continue reading

Posted in Architecture, CodeProject | Tagged | 1 Comment

What are exceptions?

This blog has been quiet for a while. I am currently writing a book about localization. Me and my partner is also getting close to release of our new startup. One of it’s features is to automatically catch unhandled exceptions and send them to a webservice for analytics. But to take full advantage of that you’ll have to use a set of exception handling best practices. I’m therefore going to write a set of exception articles. The series will end with the release of our service.

Continue reading

Posted in Architecture, CodeProject | Tagged , | 3 Comments

More relevant ads please.

I just read that Mozilla are going to block third party cookies in the next version of Firefox (optional, but blocking is on per default). That’s great. Let’s get rid of the web site/usage tracking that all advertising services has.

Continue reading

Posted in Uncategorized | 3 Comments

Azure shut me down again

Yet again I got shut down by Azure. This time the CPU quote was exceeded just a couple of hours into the new quota period.

I’ve switched to “Reserved” mode which doesn’t have the same limits (which is not said anywhere in the management interface).

Posted in Uncategorized | 3 Comments