BizTalk Receive Location crashes with the error “80131522”

When enabling BizTalk Receive location getting the error

"Event Type:
Error

Event Source:
BizTalk Server 2006

Event Category:
BizTalk Server 2006

Event ID: 5644

Computer: xyz

Description: The
Messaging Engine failed to add a receive location "rloc_abc" with URL
"C:\Test\In\*.*" to the adapter "FILE". Reason: "80131522

Taking a process dump from the procdump, in the cmd prompt
we get the error types.

Exception: E06D7363.PEAVEETypeLoadException@@
Exception: E06D7363.msc
Exception: E06D7363.PEAVEETypeLoadException@@

 

Analysing dumps and the stack is something like below.

18
00000000`0131e920 00000000`03c44eeb BTSMsgCore!CMessageHelper::GetMessageFactory+0xf7

19 00000000`0131edb0 00000000`03c150f8 BTSMsgCore!CBTTransportProxy::GetMessageFactory+0x2cb

1a 00000000`0131ee80 00000000`03c16020 BTSMsgCore!CFileWatcher::InternalInit+0x6d8

1b 00000000`0131ef50 00000000`03c111c9 BTSMsgCore!CFileWatcher::Initialize+0x140

1c 00000000`0131ef80 00000000`03c91441 BTSMsgCore!CBTMFileListener::AddReceiveEndpoint+0x249

1d 00000000`0131f020 00000000`03c947b2 BTSMsgCore!CReceiverContainer::_AddReceiveEndpoint+0xc1

1e 00000000`0131f0b0 00000000`03c87332 BTSMsgCore!CReceiverContainer::AddReceiveEndpoint+0x2f2

1f 00000000`0131f240 00000000`03c8db57 BTSMsgCore!CReceiveManager::AddReceiver+0x602

20 00000000`0131f330 00000000`03c90744 BTSMsgCore!CReceiveManager::NotifyReceivers+0x9d7

21 00000000`0131f640 00000000`03c33b7d BTSMsgCore!CReceiveManager::Initialize+0x514

22 00000000`0131f6f0 00000000`03c43162 BTSMsgCore!CBTEndpointManager::InitializeEPM+0x67d

23 00000000`0131fae0 00000000`03c437b2 BTSMsgCore!CBTEndpointManager::InitializeAgent+0x652

24 00000000`0131fc20 00000000`00f88020 BTSMsgCore!CBTEndpointManager::Start+0x2f2

25 00000000`0131fc80 00000000`00f89e48 BTSPrcCntnr!CDBMultipleRowsetWalker::Attach+0x1f80

26 00000000`0131fce0 00000000`00f88245 BTSPrcCntnr!CDBMultipleRowsetWalker::Attach+0x3da8

27 00000000`0131fda0 00000000`01006645 BTSPrcCntnr!CDBMultipleRowsetWalker::Attach+0x21a5

28 00000000`0131fe10 00000000`010083ad BTSNTSvc64!CDBMultipleRowsetWalker::Attach+0x17c5

29 00000000`0131fe70 00000000`010086ee BTSNTSvc64!CDBMultipleRowsetWalker::Attach+0x352d

2a 00000000`0131ff10 000007ff`7fee4dc6 BTSNTSvc64!CDBMultipleRowsetWalker::Attach+0x386e

2b 00000000`0131ff50 00000000`77d6b8caadvapi32!ScSvcctrlThreadW+0x25

2c 00000000`0131ff80 00000000`00000000 kernel32!BaseThreadStart+0x3a

The exception is raised when loading GetMessageFactory class which is implemented in unmanaged library  BTSMessageAgent.dll.

This CLSID is located in the registry:

HKEY_CLASSES_ROOT\CLSID\{6C90E0C2-4918-11d3-A242-00C04F60A533}

HKEY_CLASSES_ROOT\CLSID\{6C90E0C2-4918-11d3-A242-00C04F60A533}\InprocServer32

And the subkey InprocServer32 refers to the full path of the BTSMessageAgent.dll

BTSMessageAgent.dll is present in <Biztalk installation directory>\Microsoft BizTalk Server 2013 R2\Bins64\BTSMessageAgent.dll.

In our case the dll was referring to incorrect path, in which BTSMessageAgent.dll was not present.

Corrected the registry key to point to right path and dll to resolve the issue.

 Hope this helps.