Category name:Uncategorized

Why does NServiceBus sends subscription messages in my integration / unit tests?

When you reference the handlers assembly from your test assembly and this assembly initializes a bus instance and the endpoint to send messages to is a publisher it can happen that you see multiple messages being send to the endpoint. while you expected less messages. Inspecting the messages indicates subscription acknowledgement messages and you wonder why that is as you don’t want your test project to subscribe to anything at all! This happens because NServiceBus scans all available assemblies for messages handlers and when it finds these then it will subscribe to the events which results in the messages that you see in the (journal) queues.

Luckily this behavior can be disabled by calling .DoNotAutoSubscribe() during bus initialization as shown in the following example:

var bus = Configure.With()
	.DoNotAutoSubscribe()	// Needed as otherwise the client will subscribe to event messages because handler assembly is references and scanned by NServiceBus.

ThreadPool default thread count not useful for testing

Today I got reminded again that it is sometimes required to adjust thread pool settings. This time to test some possible connection issues and I required to open a number of connections simultaneously and also use them in parallel.

The test system is a virtual machine which only has one core so the defaults that .net uses are based on that. I first thought that the problems were caused by nunit but pretty soon found out that the case had to do with the thread pool. When I queried the current values via ThreadPool.GetMinThreads it told me that the thread pool used just one thread as minimal. After forcing that with ThreadPool.SetMinThreads to a thread count in where I could test my scenario I still had issues.

I am now using a custom Parellel.For which I adjusted so that I can set a different ChunkSize (set to 1) and ThreadCount for testing purposes.

DAW: Multiple ASIO devices

I have bought the Samson C03U USB microphone and after plugging it into an available USB port it worked immediately. I then wanted to use it from any of my sequencers (Cubase AI and FLStudio) but only to find out that neither can use multiple ASIO devices simultaneously. Not that difficult to understand as probably only one ASIO device can be active at a time and for that you get low latency audio out/in in return. I also saw an ASIO DirectX Full Duplex driver. Probably a ASIO host that delegates to direct sound. Had not seen that before so I selected it and there I could select the audio devices that I wanted to make available and it worked! I could use my Creative X-FI Extreme Gamer for audio out and my Samson C03U for audio in. The only big problem is that I had lots of latency. After tweaking it I found out that I could lower the buffersize to 512 samples  instead of the default 2048 which decreased the latency but it is still not very enjoyable to listen live to the incoming audio.

I remembered that I had used ASIO4ALL a long time ago when I didn’t had ASIO drivers for my onboard sound. ASIO4ALL is similar to the Directsound ASIO provider in configuration but in ASIO4ALL I could lower the buffer sizes to 64 samples which reduced the latency to acceptable levels to listen to the incoming audio. A few clicks occur in the out so I increased that to 96 samples.

I think that I have lower latency using the ASIO4ALL drivers instead of the drivers from Creative.

No CNAME on a domain record only on subdomains

We were having some mail problems. This is not always the case but we now found the culprit. The problem was that our domain record *had* a CNAME record referring to the A record of the webserver. Some mail servers will use the CNAME record instead of the MX record when the smtp server needs to be resolved. A CNAME CNAME

This will result in lots of mail servers not being able to deliver the mail. So today’s (DNS) lessons learned are:

  1. Do not set a CNAME record on your domain
  2. Do not use a CNAME record for a catch all (* as this too suffers from the same problems.

You can still use CNAME records for your ‘service’ subdomains that refer to actual hosts (A and AAAA records). This is still the most efficient way to handle your ip addresses for your actual machines especially when you also support ipv6.

The most frustrating thing here is that the behavior differs on platforms and applications so it took a while before this was discovered.

My computer hardware history

I was just chatting with a collegue about my hardware history and thought it was time for an update. My hardware list is as follows:

  • MSX2 HB-F9P
  • Amiga 500 1MB + Action Replay III
  • Amiga CDTV 1MB + DIP switch KS1.3
  • 486DX33 8MB + SB16 + GUS
  • 486DX266 32MB + SB16 + GUS
  • Pentium 200MHz MMX @ 225MHz 128MB + GUS IW + PowerVR + Voodoo2
  • Pentium 4 1GHz 512MB
  • Pentium D 3,4GHz 2GB + ATI HD2600XT + NVidia 9800GT

The first computer that I saw as a kid was an Atari 2600 which friends of mine had and that was pretty amazing. A few years later I got my own computer, the MSX2. Later the father of the friends that had the Atari 2600 bought an Amiga 2000 and I really was flabbergasted when I saw it in action. I was already in love with the MSX2 but it extended to the Amiga and soon I was an owner of an Amiga 500! I somewhere sold my Amiga hardware which I needed to do to buy a PC but now I regret that dicision :-).

The MSX died somewhere around the year 2000 when heavy rain filled the basement where it was stored but a friend wanted to get rid of his MSX2 hardware. Two Philips NMS 8280 but only one keyboard. I still have these devices and sometimes boot them up with either one of the few cartridges that survived the basement pool experiment.

Somewhere a long I also owned a NES but I was and probably never will be a console person.

I learned programming on the MSX in BASIC and a little bit hacking with disassemblers. On the Amiga I started with AMOS, REXX and later on SAS C and 68000 assembly. I then made the transition to the PC where I was first programming in Turbo Pascal combined with x86 assembler and later on Watcom C/C++. I then started programming for a living and programmed MSVC/VB6 in Visual Studio 6 in Windows with COM(+) and later on in .net 1.0.

I was always interested in other development platforms and operating systems. I experimented a lot with all kinds of languages and Linux distributions, OS/2 and BeOS but nowadays I primarily program in c# because I am a professional .net developer for a living but I still experiment in my free time although I’m not such a geek anymore as I was 10 years ago.

Howto create a certificate request with subjectAltNames with OpenSSL on Windows

Sometimes you host multiple websites on one machine on one ip address. Because the way SSL works you can have only one certificate on one ip address + port combination and then you have a problem. One solution is to host all websites on one host(name), the other is creating an SSL certificate that contains multiple hostnames. Problem is that you cannot create such a certificate from within IIS and this is where this article is for.

Download and install OpenSSL for Windows at Shining Light

  1. Create a private key for your certificate: openssl genrsa 2048 >multicert.key
  2. Create a configuration file with your certificate data
# -------------- BEGIN custom multicert.cnf -----
HOME = .
oid_section = new_oids
[ new_oids ]
[ req ]
default_days = 730
distinguished_name = req_distinguished_name
encrypt_key = no
string_mask = nombstr
req_extensions = v3_req # Extensions to add to certificate request
[ req_distinguished_name ]
commonName              = Your nice common name
commonName_default      =
commonName_max = 64
[ v3_req ],,DNS:*
# -------------- END custom openssl.cnf -----


  1. Create a certificate request: openssl req -new -key multicert.key -out multicert.csr -config multicert.cfg
  2. Submit your certificate request to your CA (I often use
  3. Save the CA certificate request response to a file multicert.cer
  4. Create a PFX file that contains both the public and private key: openssl pkcs12 -export -out multicert.pfx -in multicert.cer -inkey multicert.key

Note that I used the same domain name for all entries and only changed the subdomains but I could just as easily used different domainnames as long as you are allowed to use those domainnames according to how you are registered at the CA that you are going to use.

And voila there you have your PFX file that can be loaded by IIS and be used for several websites that match the included hostnames on one ip adress + port combination.

Configure hostheaders for SSL

You still need to add the correct hostheader on each website on the commandline as this cannot be done from within the management console.


cscript.exe adsutil.vbs set /w3svc/{site identifier}/AccessSSL TRUE

Where {site identifier} is the id/number  of the website which you can see when you click the “Websites” node in the IIS6 management console. Click here for detailed instructions for IIS6.


appcmd set site /"MySite V2"/+bindings.[protocol='https',bindingInformation='*']

Instructions for IIS7

What’s your worst day as a coder?

Jeremy has a nice post called what’s your worst day as a coder and I needed to post my own list:

  1. When I need to fix a bug in a module and opening a 7500+ LOC (non generated) class file (that really happened somewhere in the past).
  2. When I interview a candidate to find out he cannot reverse an array.
  3. When I’m using a designer for more then 10% of my time.
  4. Would forced to use sourcesafe.
  5. When I broke the build.
  6. Would not code a single line.

Just a brainflush. Will probably update the post in the near future 🙂

Import/export by using DataSet WriteXml and ReadXml

I just tried to create a simpel import/export feature in one of our applications based on XML. My first thought was: Create a typed dataset and for export just serialize it to XML with the WriteXml method and for import deserialize it by using ReadXml.

Well the write part created exactly the file that I wanted but the ReadXml did not work as expected. No exceptions occured but no data was read so I could not add the data to the database. I remembered that I probably had to do with a schema option. Either at the write or the read. I wanted the write to behave like it was doing now. So browsing MSDN gave me the answer that I had to use the XmlReadMode.InferSchema parameter to the ReadXml method. That uses typed dataset information to check for data consistency.

So now my simple import/export is working again and it appears that my (typed) dataset knowledge was a bit rusted by not using it for quite a while.

MonoDevelop 1.0 and Mono 1.9.1 on openSUSE 10.3

This weekend I moved from Ubuntu 7.10 to openSUSE 10.3 after using the distro in the vmware image that the mono-project hosts. I was impressed how quick it was installed and still impressed by the ease of use of its package management. I am now running the latest mono binaries (1.9.1) together with MonoDevelop 1.0. I needed to add the same repository for both and after upgrading most packages through yast I was finished.

I tried opening a visual studio 2008 solution which contains an .net 2.0 project with nunit tests. It is a library used by a service. Ofcourse the service won’t work but the library uses sockets, generics and multi-threading code and wasn’t sure that my unit tests would all be successful but they did!

Next test will be to see if the service can easily be ported and see if the nhibernate code will also work on mono and still get the same performance as the application on windows.

Sourcesafe API magic

What is wrong with the following code?

IVSSItem item;
IVSSVersions versions = item.get_Versions(0);

for(int versionIndex=0;versionIndex<item.Count;++versionIndex)
    IVSSVersion version = versions[versionIndex];

The .Count returns the total number of actions on a item including includes labels, rollbacks, and checkins. However, the indexer ONLY gives access to the actual versions of an item. This is strange behaviour as normally you expect that the indexer range is the same as the .Count property.

However, the indexer has a base of 1 instead of 0 (zero) which is the reason to investigate how these interface are actually behaving as I had weird results.

The correct way to only retrieve actual versions is to do this is the following:

// This will iterate through the actual versions
IVSSItem item;
IVSSVersions versions = item.get_Versions(0);
for (int c = item.VersionNumber; c>0; –c)
    IVSSVersion version = versions;

What is done here is to replace the IVSSVersions.Count with IVSSItem.VersionNumber

Retrieving all actions: 

// This will also retrieve labels!!
// First item returned is the latest action performed!
foreach (IVSSVersion v in item.get_Versions(0))
    // …


IVSSVersions versions = item.get_Versions(0); 

for(int versionIndex=0;versionIndex<item.Count;++versionIndex)


IVSSVersion version = versions[versionIndex]; 

                 // This will also retrieve labels!!
                // First item returned is the latest action performed!
                foreach (IVSSVersion v in item.get_Versions(0))

                // This will iterate through the actual versions
                IVSSVersions versions = item.get_Versions(0);
                for (int c = item.VersionNumber; c > 0; –c)
                    IVSSVersion version = versions;

  • Recent Posts
  • Recent Comments
  • Archives
  • Categories
  • Meta