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.


Comments

Reginald Henderson
PERFECT. This is exactly what I needed!!! Thanks dude.
2009-07-10 12:46 UTC
Hi Reginal

Thank you for your message - I am happy that my post was helpful to you.
2009-07-10 19:23 UTC
Thanks for this, I stumbled on this one today. My issue was simply that it was still compiling for "Any CPU". I simply changed it to x86, and there were no problems.
2010-03-07 02:45 UTC
Bernhard
Thanks, that did the job!
2011-09-09 07:49 UTC
Michael N
Thank you for the information; this worked for me!

I was trying to find out why SharePoint Workspace did not work on my workstation. It was failing with the "Class not found" 80040154 error, and I found your article with a Google search on the CLSID. Installing Microsoft Sync Framework 1.0 SP1 fixed the problem, and I would never have known where to look without your article.
2011-09-14 11:25 UTC


Wish to comment?

You can add a comment to this post by sending me a pull request. Alternatively, you can discuss this post on Twitter or Google Plus, or somewhere else with a permalink. Ping me with the link, and I may add it as a comment.

Published

Thursday, 21 May 2009 18:54:01 UTC

Tags



"Our team wholeheartedly endorses Mark. His expert service provides tremendous value."
Hire me!