When I tried to deploy a biztalk application to the server, I got an the error ?Could not change the bindings for orchestration ‘orchestration_name_here’, Version=x.x.x.x,Culture=neutral, PublicKeyToken=sometoken’ as one or more instances of the orchestration still exist?.
Now what? What does it mean? Quite simply, you have a resumable message sitting in the queue. If this message is important, you need to fix the issue with the message and resume the message or terminate the instance.
Removing instances using the BizTalk Administration Tool
In the BizTalk Administration Group click in the left pane on ?BizTalk Group [Name of Computer/Name of Management database]?. In the right pane the ?Group Overview? appears. Click on the tab page ?New query? to create a query that searches for the suspended instances. In the ?Query Expression? grid the first Search field is already selected, namely ?Search For?, also the ?Equals? operator is already filled in in the second field. All we have to do in the ?Value?-field is search for suspended instances. And? lucky us: when we open the dropdown box we see that ?Suspended Service Instances? is one of the values we can choose! Next, we run the query by hitting the button with the label ‘Run Query’. The grid ?Query results? now contains all suspended instances found. All we need to do is select all suspended instances, right click on the selection and choose ?Terminate Instances?. The BizTalk Administration Tool asks for confirmation and removes the instances. When you rerun the query, the instances will be removed and the orchestration can be undeployed/redeployed. So far for the polite manner.
Removing instances using a Stored Procedure
The less polite manner to remove suspended instances is by running a Stored Procedure which will clean up the MessageBox. Attention: this is NOT a recommended procedure on production environments!
Open the SQL Server Management Studio and connect to the database server. In the left pane expand the server-node and the Databases-node. Next, click on the MessageBox-database (BizTalkMsgDb) and hit the ?New Query?-button in the toolbar. In the right pane you can enter SQL commands. Since you selected the MessageBox-database in the left pane, the commands are executed against that database. Now type: ‘exec bts_CleanupMsgbox 0’ (without the quotes) and hit the ?! Execute?-button in the toolbar. All suspended instances will now be removed. You can now undeploy/redeploy the orchestration.