I mentioned yesterday a special case of Roy's excellent article on using Enterprise Services with database unit testing where it seems to produce an inconsistent result with NUnit. The case involves a Server Application (I didn't try a Library Application for my test), Oracle, and NUnit. The issue is I can test successfully every other time, with a RollBack at the end of each transaction in order to put the database back to its original state. It's the every other time after that fails with these messages:
ORA-03113: end-of-file on communication channel
System.Runtime.InteropServices.COMException : You made a method call on a COM+ component that has a transaction that has already aborted or in the process of aborting.
Has anyone seen a solution to these problems? In our case, the way we solved this ultimately was to do the standard way of testing database layer code by either rebuilding the data schema over again (getting the data into a consistent state) or writing the tests in such a way as not needing to do a RollBack. For unique constraint tests, I would use a GUID appended to a value.
As far as I can tell, Roy's usage of NUnit and Enterprise Services works perfectly with SQL Server, and I see it as a great solution. I think the issues I see with Oracle have to do with some missing or wrongly configured Oracle/MSDTC settings rather than flaws in Roy's approach. If anyone has a clue about the Oracle messages above, it would be greatly appreciated, as well as possibly helping someone else.
Update: If memory serves me correctly, I think we also determined at the time this oddity was related to an existing bug in v. 1.1 code with the System.Data.OracleClient namespace. A bug fix was available, but only if it was a major problem (not publically available). I can test in Whidbey code to determine if this issues is now resolved.
Roy Oshorove has written a very good introductory article on using Enterprise Services to do Test Driven Development (using NUnit) against database classes.
Our team was doing this 8 months ago when we were in the thick of ES development (see some of my blog posts from that time).
In our case, we had great success with this, but at times, we also had inconsistencies and problems. In particular, if you are testing Server Applications, you may have objects that don't get released because the client, in this case NUnit, needs to call Dispose. Also, since NUnit itself is not referencing EnterpriseServices, you may have other inconsistencies in your transactions that are not cleaned up properly.
We also had problems with Oracle (both providers from Microsoft and Oracle) in using Enterprise Services in combination with NUnit. At times we would see a test succeed individually, but it would pass or fail inconsistently when running all tests, based on the inconsistent state of the transactions mentioned above.
I like Roy's approach, though, and I will be interested in determining if this has helped solve some of the problems we were seeing with our results.
Update: In answer to Roy's question on this post regarding how I approached this:
Today, I coded a sample in the format proposed by Roy's article. The only real difference between his code and my previous code was I placed the RollBack call in all the test classes, and not in a base class.
Testing with Oracle, I get the green light and everything works correctly, for the first time. The second time, I get the dreaded Oracle "inconsistent state" error: "ORA-03113: end-of-file on communication channel". On the third try, I get a green light again. And, it repeats the error the fourth time, and so on. Back and forth.
Update 2: A little more information. The actual exception is this: System.Runtime.InteropServices.COMException : You made a method call on a COM+ component that has a transaction that has already aborted or in the process of aborting.
One item I noticed in Roy's code is that if you are testing a Server Application, and don't explicitly call Dispose in the test code, you will see objects instantiating in the Components Services view, but not releasing.
A slight improvement to Roy's code would be to wrap the inner code with either a “using” statement or explicitly write the try/catch/finally in order to catch exceptions and call Dispose on the object.
It still doesn't solve my Oracle problem, but just some further ideas.
I spoke with Sam Gentile a couple of nights ago, and he mentioned the 1st Boston Blogger Dinner was a big success. Out of that dinner came many volunteers for a new .Net group, including my former boss Kevin Hegg as the speaker liaison.
The first Boston .Net Group meeting is on July 1 at 5:00 pm at the Adesso offices. That's great news! Sam will be the user group leader. The first topic will be Sam's excellent CLR Internals talk he gave to the New Hampshire group and to the Vermont group, among others.
Check out Sam's post for more details.
Florin Lazar has some excellent tips posted regarding the new Windows XP SP2 Release Candidate 2 and any current distributed transactions you may have running. There are some changes that you need to be aware for your applications.
Florin also asks for feedback regarding any issues you may find:
I recommend and I encourage you to give a try to this release candidate for XP SP2 on your test systems and send your feedback to the XP SP2 preview newsgroups: http://communities.microsoft.com/newsgroups/default.asp?icp=xpsp2&slcid=us . Thanks!
Aaron Margosis has started a new blog, and he is already trying to convince developers (and users) to run as non-Admin. Excellent! That will be part of my Writing Least Privileged Applications topic this October at WIN-DEV 2004 as well, but in the meantime, take a look at Aaron's posts:
Not running as admin ...
Why you shouldn't run as admin ... (this one is especially good as it talks about the dangers of malware when you run as Admin)
Microsoft Virtual Server 2005, Enterprise Edition, Release Candidate
Now available as a free download, the Virtual Server 2005 RC is the most cost-effective virtual machine solution designed for the Windows Server 2003 platform to increase operational efficiency in software test and development, legacy application migration, and server consolidation scenarios.
A release candidate is software still in its development stage. Microsoft will be completing development, testing, and certification before making the final version of Virtual Server 2005 available later in 2004.
Important: This release candidate software expires January 1, 2005. An end-user license agreement (EULA) is required for its use, which you can download using the link to the right. The Virtual Server 2005 RC software is intended for evaluation purposes only and may not be used in a production environment.
The following items are included in the release candidate download:
Virtual Server 2005, Enterprise Edition
Getting Started Guide
Virtual Server Administrator's Guide
Virtual Server Programmer's Guide
Note: The Virtual Server 2005 RC is available only in English.
Here is something I have been looking forward to:
Release Canadidate 2 of Windows XP Service Pack 2 is now available for download. Here's a link and a bit about it:
Windows XP Service Pack 2 Release Candidate 2 Preview
To aid IT professionals in planning and testing for the deployment of Windows XP Service Pack 2 (SP2), Microsoft is making available this preview, based on Release Candidate 2 (RC2) of SP2. Additionally, we have established 11 newsgroups for sharing information.
[by way of Brian Johnson]
For more information regarding the changes, take a look at these [by way of Anil John]:
Windows XP Service Pack 2 - Security Information for Developers 
With Windows XP Service Pack 2 (SP2), Microsoft is introducing a set of security technologies that will help improve Windows XP-based computers' ability to withstand malicious attacks from viruses and worms. These technologies include:
- Network protection
- Memory protection
- Improved email security
- Safer browsing
Together, these security technologies will help make it more difficult to attack Windows XP, even if the latest patches or updates aren't applied. These security technologies together are particularly useful mitigation against worms and viruses. To developers these technologies will have impacts on the applications that they create and the tools they use. This page contains resources to assist developers in dealing with these impacts.
How to Make Your Web Site Work with Windows XP Service Pack 2 
"Examine the new security features in Windows XP SP2 that affect Internet Explorer and ActiveX controls, file downloads, pop-up windows, and more."
Security improvements in the upcoming Windows XP Service Pack 2 
"Rebecca Norlander, group manager .... in charge of the Windows XP Service Pack 2 effort invited us over to chat about the upcoming Service Pack.
...So, for this first interview (the rest will come over the next week or so) we wondered just what was the big deal about security in Service Pack 2"
By way of Chris Sells:
Richard Turner, a PM on the Indigo team, addresses the biggest misperception about Indigo in this Channel9 video.
Bottom line: Microsoft is not taking MSMQ, COM+ or Remoting out of the platform; it's just that Indigo, which subsumes the features of these other technologies, will do it all better.
I was talking with one of my clients yesterday about how to solve a distributed architecture problem. In the end, I had to say the solution they were looking for will be Indigo. But, the beauty today is solutions written in most of the current technologies will migrate quite nicely to Indigo later on (especially ASMX). Plus, those applications using current technologies (COM+/ES, Remoting, Web Services) will STILL work without Indigo in the future as well. That's great news for understanding how to put together applications today that will still be relevant in the future.