Recently I have spent a lot of time working with the Commerce Server 2007 Orders Adapters for BizTalk. 

Getting it set-up and running on a single machine with BizTalk and Commerce Server together was not too hard (although anyone who thought BizTalk 2004 was hard to install should try installing Commerce Server).  Getting everything to work correctly on a 64-bit BizTalk Server installation was another story.

I was running BizTalk 2006 R2 64-bit with a 64-bit process Host.  I was setting up the Commerce Server Order Receive Adapter just like I had many times, only to receive the following two errors:

90% of the time:

Access to the registry key ‘HKEY_LOCAL_MACHINE\Software\Microsoft\Commerce Server 2007 BizTalk Adapters\Orders\<some key>’ is denied.

Ref_Err

10% of the time:

The Messaging Engine failed to update the configuration for the receive location “Receive Location1” with URL “<some address> for adapter “Commerce Server Orders”. Reason: “Object reference not set to an instance of an object.”.

Obj_Err

For those of you who have not worked with the Orders Adapter before, when you create a new Receive Location the adapter creates a local registry key to use to store the last polling time.  When I set up this receive location, I checked the registry by doing a search for “<some key>”.  I found the key inside the registry and noticed it was automatically created for me by the BizTalk Adapter as it should have been.

So what was the registry permission problem?

This page in the Commerce Server 2007 help guide was helpful in finding the bug… I mean problem.  This states that on a 64-bit BizTalk Server, the Commerce Server Adapter uses two different registry locations depending on if your host is 32-bit or 64-bit.

For a 32-bit Host, the keys should be here:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Commerce Server 2007 BizTalk Adapters

For a 64-bit Host, the keys should be here:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Commerce Server 2007 BizTalk Adapters

Since my host is a 64-bit Host, the error message above is correct in the location it is looking for the registry settings. 

So what happened to the settings I saw in the registry?  It turns out they were put into the Wow6432Node and I did not notice the full path to the registry key.

The fix was simple.  All I had to do is move the keys the Adapter created in the incorrect location into the expected location for the 64-bit Host.  Note that this process will need to be done any time the Registry Key changes, which on a production server should be almost never or any time you add a new receive location.

To summarize:
When running a 64-bit Host with the Commerce Server Orders BizTalk Adapter, you need to move the auto created registry keys from the Wow6432Node location to the correct location.

Note that 32-bit Hosts running on 64-bit BizTalk Servers do not have any issues, nor do 32-bit BizTalk Servers.