BizTalk.Operations TerminateInstance SQL Error


I'm getting the following when trying terminate an instance calling TerminateInstance on Operations object:

System.Data.SqlClient.SqlException (0x80131904): Conversion failed when converting from a character string to uniqueidentifier.
 at Microsoft.BizTalk.Database.DatabaseAccessor.ExecuteReader(Int32 procIndex, Object[] procParams)
 at Microsoft.BizTalk.Operations.OperationsMessageBoxAccessor.ops_OperateOnInstances(Int32 snOperation, Int32 fMultiMessagebox, Guid uidInstanceID, String nvcApplication, Int32 snApplicationOperator, String nvcHost, Int32 snHostOperator, Int32 nServiceClass, Int32 snServiceClassOperator, Guid uidServiceType, Int32 snServiceTypeOperator, Int32 nStatus, Int32 snStatusOperator, Int32 nPendingOperation, Int32 snPendingOperationOperator, DateTime dtPendingOperationTimeFrom, DateTime dtPendingOperationTimeUntil, DateTime dtStartFrom, DateTime dtStartUntil, String nvcErrorCode, Int32 snErrorCodeOperator, String nvcErrorDescription, Int32 snErrorDescriptionOperator, String nvcURI, Int32 snURIOperator, DateTime dtStartSuspend, DateTime dtEndSuspend, String nvcAdapter, Int32 snAdapterOperator, Int32 nGroupingCriteria, Int32 nGroupingMinCount, Int32 nMaxMatches, Guid uidAccessorID, Int32 nIsMasterMsgBox)
 at Microsoft.BizTalk.Operations.OperationsGroup.OperateOnInstances(InstanceFilter ifc, MessageBoxDatabase mb, InstanceOperation op)
 at Microsoft.BizTalk.Operations.OperationsGroup.TerminateInstances(InstanceFilter ifc, MessageBoxDatabase mb)
 at Microsoft.BizTalk.Operations.OperationsGroup.TerminateInstances(InstanceFilter ifc)
 at Microsoft.BizTalk.Operations.OperationsGroup.TerminateInstances(Guid instanceID)
 at Microsoft.BizTalk.Operations.BizTalkOperations.TerminateInstance(Guid instanceID)

The code I'm executing is correct so I won't waste space putting it here. It's BizTalk 2013 R2 running on SQL 2014 backend, all on the same box. Windows Server 2012 R2. What could possibly be the cause, I've tried taking parsing the Guid out to a string and back again, I'm wondering if anything to do with the Arch. but everything is running as 64bit.

Anyway, anyone have any ideas, had the same problem... similar?

asked on Stack Overflow Dec 13, 2014 by Calvin • edited Dec 14, 2014 by Dijkgraaf

2 Answers


OK. Turns out, despite thinking I had the right code, I didn't...

I was calling the TerminateInstance method on the SAME BizTalkOperations object that I had used to perform the query to get the ServiceInstances initially.

The problem went away, when I created a new BizTalkOperations object and called TerminateInstance on that, passing the InstanceID.

Or at least some strange stuff is going on internally that I am not privy to, whether this is by design or just a bug, it's something to be aware.

answered on Stack Overflow Dec 13, 2014 by Calvin

I recently stumbled upon the same strange behaviour in a BizTalk 2016 setup with multiple MessageBoxDBs, with only on MessageBoxDB the error was not happening.

Here is my code to work around this strange bug

List<System.Guid> suspendedInstances = new List<System.Guid>();
using (var opsRead = new BizTalkOperations())
    foreach (MessageBoxServiceInstance item in opsRead.GetServiceInstances())
        if (item.InstanceStatus == InstanceStatus.Suspended)

using(var opsWrite = new BizTalkOperations())
    foreach(var itemId in suspendedInstances)
answered on Stack Overflow Jul 29, 2020 by SeriousITGuy • edited Jul 29, 2020 by Roberto Caboni

User contributions licensed under CC BY-SA 3.0