"Cannot access a disposed object. Object name: 'TransactionScope' "
On investigation, I found that this can happen when:
- Recieve port/location does not have a corresponding subscription (orchestration / send port) created.
- Send Port is created but not enlisted. This is same as no subscription found in database.
When enable transactions check box is clicked while configuring receive location as shown below:
Behind the scenes, a transaction scope object is created that will attach itself to incoming message sent from a client and form a one continious transaction involving MSDTC. This enables WCF client to control the whole transaction involving Biztalk. Client can use "commit" and "rollback" commands to commit and rollback message in Biztalk messagebox database. Very powerful!
At core, Biztalk works on pub-sub mechanism. In absence of any subscription, receive location can't really participate in transaction and create a transaction object. Hence the error is raised "cannot access a dispose object" (transaction object)
Solution is simple: Create a subscription for the receive port/location in form of a send port or an orchestration.