Wednesday, March 23, 2011

NServiceBus and SQLite in .NET 4.0

I've just used the better part of a day trying to figure out how to get System.Data.SQLite.dll to work with NServiceBus in a .NET 4.0 project in VS2010.

The problem is if you just set it up like normal, you'll get the following error:
"Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information."

This is because there's no .NET 4.0 version of the dll released yet (2011-03-23). There's only a .NET 2.0 version and it contains unmanaged code. So what we must do it to explicitly tell the project that it is ok to use the dll by adding some configuration. This solution is documented in many articles on the Internet, but I could not get it to work with NServiceBus - or rather the NServiceBus.Host.exe to be precise which actually makes all the difference.

As mentioned in various articles on the Internet I put the configuration in app.config of the project and then exactly nothing happened. After much frustration I stumbled over this article:

The trick is to put the configuration in the NServiceBus.Host.exe.config file like this:

<?xml version="1.0" encoding="utf-8" ?>
<!-- This is needed in order to get System.Data.SQLite to work in .NET 4.0, at least
until a .NET 4.0 compatible version of System.Data.SQLite is released. -->
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>

NOTE: you must also ensure that the "Copy to Output Directory" setting for the config file is set to one of the copy options.

This did the trick.

Friday, March 18, 2011

Fuzzy text in VS2010

So I finally moved to Visual Studio 2010. This is a very nice IDE, but one thing that annoys me is that the text (code) seems fuzzy compared to VS2008. My eyes don't like it.

I googled it and there were several suggestions of using the free Visual Studio theme editor "Visual Studio Color Theme Editor":

However, this only allows for changing the theme of everything around the code area - not the code area itself.

Then I found some articles about the fonts used in VS2010 and it turned out that it uses a font called Consolas for the code whereas VS2008 uses Courier New. So I simply changed Consolas to Courier New in VS2010 and my eyes were instantly happy :-)