views:

89

answers:

1

I have some VB.NET code that creates a TransactionScope instance:

LoggingUtility.LogDebug("UpdateCallTable", "SatComCallDataImporter", "About to associate call data with contracts")
Using ts = New TransactionScope()
    LoggingUtility.LogDebug("UpdateCallTable", "SatComCallDataImporter", "Getting all unimported SatCom calls")

My application is throwing an exception on the call to the creation of a new TransactionScope, with "Object reference not set to an instance of an object.". The exception isn't thrown on my development machine or my test machine; only on the customers production machine, and I have no idea why. I've placed debug lines immediately before and after this line so I'm positive it is this line causing the problem.

A have used TransactionScopes throughout the application and this is the only place throwing the exception on the client machine.

"About to associate call data with contracts" gets written to the log and the next log entry is the "Object reference not set to an instance of an object".

Code works fine if I move it out of a transaction.

I've been struggling with this for 4 days now and have got no closer.

+1  A: 

Perhaps you have an issue with MSDTC?

I'd lean more towards a coding error though, because the TransactionScope object should be initialised and non null, but it will be indicating an error.

Perhaps showing us the code might help us further?

UPDATE: I've had experience with logging engines failing to log the line before an exception, which is sometimes caused by release mode reordering, or the routine doesn't flush actively and the app crashes nastily before it can complete.

I would suggest placing a logging line directly after you using() statement to assert that the TransactionScope is not null. Given the way you have used the code, it is IMPOSSIBLE for the result of that code to return null, the constructor must throw an exception if the constructor fails, otherwise you have a non null transaction scope.

Perhaps a little more code and this test might help some more?

Spence
Happy to show the code if it helps, but that's the line of code that is failing. The surrounding lines are debug lines. I've checked the MSDTC settings on all machines and they are identical.
rob_g
Updated my answer
Spence
Actually put in a line that states If IsNothing(ts) then throw new NullReferenceException() Add a try catch around it too!
Spence
I'll throw some more debug code in and see how I go :)
rob_g