The Visual Studio hosting process and 64-bit Windows

I’ve recently started working with Outlook Redemption, an excellent alternative to direct MAPI calls. Some of the other devs on my team wrote some libraries that use it, complete with unit tests. All the code and unit tests run fine on my machine (VS2008, 64-bit Windows).

                    |   |
                    |   |
                    |   |
                 /'\|   |/'\..
             /~\|   |   |   | \
            |   =[@]=   |   |  \
            |   |   |   |   |   \
            | ~   ~   ~   ~ |`   )
            |                   /
             \                 /
              \               /
               \    _____    /
                | (( +==)) |

In order to illustrate some functionality, I needed to write a simple console application that used the code that these other devs wrote, so I referenced it and tried it… and was given an exception (the computer version of the middle finger):

Unhandled Exception: System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {29AB7A12-B531-450E-8F7A-EA94C2F3C05F} failed due to the following error: 80040154.

My first instinct was to search through the registry for the CLSID. Sure enough, it was there, and everything looked right. It has to be — otherwise, the unit tests (which use the exact same code) wouldn’t work.

The next thing I tried was unregistering and re-registering Redemption.dll (using regsvr32). No luck; unit tests work, console app fails.

Reboot? No luck; unit tests work, console app fails.

I did some reading, and apparently MSTest runs as a 32-bit application (though it can be run as 64-bit). I tried forcing Visual Studio to compile in x86? No luck; unit tests work, console app fails. Forcing Visual Studio to compile in x64 didn’t help either.

More reading, and I started to understand more about what the “Any CPU” platform compilation means, and the trials and tribulations of programming for 64-bit Windows. Now I am smarter, but I still can’t get my damn simple console application to work!

Seemingly out of options, I found myself staring at the Debug output directory, and noticed something:


I went ahead and turned off the Visual Studio hosting process, and viola! Everything works fine. I don’t know why, exactly (though I’m sure it’s related to the difference between 32- and 64-bit processes), but it fixed my issue, so if you have the same problem, hopefully it’ll fix yours.