Wednesday, March 14, 2007

.Net 2 Upgrade causing COM+ problems

I've been using .Net 1.1 since leaving university just over 3 years ago now, but over the last couple of weeks we've been updating to .Net 2. It's not proven to be an easy transition, and not only because of the updated web application format that Visual Studio 2005 now uses.

When our build got to our SMS XML Web Service APIs we had a lot of these errors:

The requested operation requires that the current context have a Transaction, and it does not.

The APIs use COM+ as a business logic layer, and initially it seemed to only be a problem when we had a ServicedComponent calling a non-ServicedComponent which in turn called a different ServicedComponent. However, we refactored some code around to remove the middle section, and the error still threw.

A Google search for the error doesn't find that many pages, but luckily there is a knowledge base article on it. There is also even a patch for it, but only for Windows 2003 Server editions, and (like most people) we don't actually develop on a server operating system.

There is no hotfix for Windows XP Professional, and no usable workaround for that OS was listed either. As a last ditch effort we attempted the registry fix workaround listed on that page, which is to add a new key string value for DisablePromotableTransactions in HKEY_LOCAL_MACHINE\Software\COM3, and set the value to Y.

But look in the registry on a WinXP box and you'll find that the required registry location doesn't exist. There is however a HKEY_LOCAL_MACHINE\Software\Microsoft\COM3. Not knowing whether it would work, we just tried putting the entry there instead.

And it worked. The tests passed and the build continued. No more COM+ problems after that.

But it does raise the question of what else that registry key is controlling. The research that we've done on it seems to suggest promotable transactions are a new feature of Sql Server 2005. As we aren't using that in either production or development we're probably ok. Also, it's only a problem on our development machines, as production boxes do have the hotfix applied.


Anonymous said...

Great blog! This is just what I need :)

Ian Dykes said...

I've just been back to this as there's a new development machine here that required the registry change.

Noticed that I'd put "add a new key", when it should have read "add a new string value to the key".

I've changed the post accordingly, apologies for any confusion.