About the author

Steven Harmansteven harman :: makes sweet software with computers!

For recent posts and more about me, scroll to the bottom.

Subscribe

  • Subscribe to my feed. via RSS
  • Subscribe via email via email

News

Badges

  • Subtext Project
  • Support Subtext

Using MbUnit with COM+ 1.5 transactions... a big Gotcha!

Its been a while since I took my first steps into the wild world of software engineering, but only recently did I finally start down the Test Driven Development path. I have always been a proponent of Extreme Programming but seeing as the majority of my experience, prior to joining the subText Project Team, is from the corporate world, I'd never had the opportunity to truly implement many of the practices in my daily design/development work. I'm not saying that _the corporate world_ doesn't believe in EP and/or TDD, just that our shop doesn't follow these techniques. Anyhow, I finally decided that it was time to take the plunge.

After installing MbUnit 2.3.17 I simply fired up the MbUnit GUI, loaded my subText unitTest Assemblies, hit the Run button, and...

An error occurred while enlisting in a distributed transaction
WTF? A quick chat w/Phil revealed the issue... most of the subText tests need to touch a database (MS SQL Server in my case) and in an effort to keep the db clean, we use the RollBack attribute for our MbUnit tests. This attribute works by enlisting a COM+ 1.5 transaction from the local Distributed Transaction Coordinator (DTC). This in and of itself is not an issue, but it does cause problems when the db you're trying to access sits on a remote server, as in my case. The COM+ 1.5 transaction attempts to use Transaction Internet Protocol (TIP) to access the remote SQL server. The problem is that Win2k3 Server & WinXP Pro SP2 both disable TIP by default.

The solution: Enable & Configure TIP on BOTH the remote server and the local dev box. Here's how:

1) On the remote server (Win2k3 Server running SQL Server 2000 in my case) open the Component Services MMC Snap-In (Start -> Control Panel -> Administrative Tools -> Component Services )


2) Now, in the Component Services Snap-In, navigate down the tree until you get to My Computer, and then Right-click and select Properties.


3) Under the MSDTC tab, click the Security Configuration button and then be sure that top of the Security Configuration page has the following options checked: Network DTC Access, Allow Remote Clients, Allow Remote Administration, Allow Inbound, Allow Outbound, No Authentication Required*, Enable Transaction Internet Protocol (TIP) Transactions, and finally Enable XA Transactions.

Just to be sure that the changes took, go ahead and bounce the box... I know you _shouldn't have to_, but lets be honest, how often does this type of thing work the way it's supposed to.

* -> This is necessary if any of the following are true:

  • The network access is between computers that are running Microsoft Windows 2000.
  • The network access is between two domains that do not have a mutual trust configured.
  • The network access is between computers that are members of a workgroup.
Doing this solved the 2nd issue I ran into which was an Access Denied error when trying to run a transaction.

4) At this point, move to the local dev box and again navigate to the MSDTC -> Security Configuration Properties tab of the Component Services Snap-In. Now, select the same options as above EXCEPT I do not believe you need to check the Enable XA Transactions option, so you can leave it blank. Again, you need to OK out of all open windows and then bounce the box.

At this point, you should be good to go! So fire up MbUnit, load your assembly, and then RUN. I hope that you too see a whole lot of GREEN, and that any red is not a result of failing to enlist a new transaction!

What others are saying.

# Enabling Distributed Rollbacks With NUnit and MbUnit
Gravatar you've been HAACKED
Dec 29, 2005
# DTC and Windows XP SP2
Gravatar Code Jock
Aug 09, 2006
Whilst developing a COM+ Application, which was temporarily hosted under Windows XP Pro SP2, I was getting the error message...
# re: I have seen the light and it is called MbUnit
Gravatar .Avery Blog
Oct 04, 2006
re: I have seen the light and it is called MbUnit
# re: Using MbUnit with COM+ 1.5 transactions... a big Gotcha!
Gravatar Jeremy
Nov 07, 2006
Man, this totally saved me. It was the "No Authentication Required" part that was giving me trouble. Thanks Steve!
# Setting up for MbUnit database rollback
Steve Harman has some great notes on this .
# Setting up for MbUnit database rollback
Gravatar WPF Community Bloggers
Nov 24, 2006
Steve Harman has some great notes on this .
# Solving "An error occurred while enlisting in a distributed transaction" error when using Rollback Attribute or COM+ in unit tests
One of the things I'm most proud of creating is XtUnit , which allows Rolling back the effects of a unit
# An error occurred while enlisting in a distributed transaction
Gravatar Prasanth
Dec 01, 2006
An error occurred while enlisting in a distributed transaction

i am getting the above error but not frequently
some of my trasaction will be bounced back
with this error if i try again the transaction will work fine , any help why it is failing is appreciated
# SQL Server Installation and MSDTC
Gravatar StevenHarman.net
Mar 27, 2007
SQL Server Installation and MSDTC
Comments have been closed on this topic.