This post describes a particular problem I ran into when working with the Microsoft Sync Framework. Since I found a solution, I’m sharing it here to help others. If you are not having this particular problem, it’s quite safe to skip reading the rest of the post :)
While developing a SyncProvider, I wanted to create and execute a series of Integration Tests to drive my development effort. In order to do that, I wrote a simple test that simply created a SyncOrchestrator instance and invoked its Synchronize method.
Running this test gave me this error message:
“Microsoft.Synchronization.SyncException: Retrieving the COM class factory for component with CLSID {A7B3B4EE-925C-4D6C-B007-A4A6A0B09143} failed due to the following error: 80040154. ---> System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {A7B3B4EE-925C-4D6C-B007-A4A6A0B09143} failed due to the following error: 80040154.”
It’s not often I see a COMException these days, so I was initially baffled. Since the Sync Framework also has an unmanaged API, this is really not surprising, but that didn’t help me solve my problem.
What was even weirder was that when I tried running the same code in my application, this exception was not being thrown.
It took me a couple of hours to figure out what the problem was.
Here’s a little hint: I’m running Windows Vista x64.
No: The issue is not that I’m running Vista :)
Even on x64, Visual Studio runs as a 32-bit process, and so does MSTest. Since my code was compiled to Any CPU, the application itself was running in a 64-bit process, whereas my unit test was running in a 32-bit process.
I tried changing my build output to x86, and now the application started throwing the same exception as the unit test did.
In other words: When running in a 64-bit process, everything worked as intended. When running in a 32-bit process, a COMException was thrown.
As it turned out, I had only installed the 64-bit version of the Sync Framework, and even though the SDK seems to contain builds for the other architectures as well, the COM Server wasn’t properly registered for 32-bit use.
To resolve this issue, I downloaded and installed the x86 version of the Sync Framework as well, and the problem went away.
If you are having the same problem, I hope this post helps you resolve it.
Remember Me
a@href@title, b, em, i, strike, strong
Page rendered at Tuesday, February 07, 2012 5:55:12 PM (Romance Standard Time, UTC+01:00)
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.