views:

279

answers:

2

In my context I have Navision involved, but perhaps this is related to every COM interop scenario, I don't know.

Anyway, the situation: - I've a simple C# component registered for COM Interop - I call it from Navision, just before inserting a new record (for who knows Navision, inside an 'OnInsert' trigger, thus in the context of a transaction)

I was expecting to have an ambient transaction, but System.Transactions.Transaction.Current is null.

Am I missing something? Are there particular techniques I should adopt to make the transaction flow into my interop component?

A: 

Are you trying to begin a transaction in NAV and then access that transaction using your COM object?

It sounds like the System.Transactions.Transaction.Current value is null because you haven't initialised a transaction in your COM object - can you post a code sample of it?

Although from your post it sounds like you're expecting the Transaction.Current value to refer to the transaction you have initiated in NAV and I don't think this is what will happen, or is even possible!

What is your COM object trying to do with the transaction? Perhaps there is a different approach we could take?

Rob Burke
well, It's not me that begin the transaction. But I know for sure the Navision OnInsert trigger runs in a transactional context.The implementation of the component I run in the Navision plugin it's mine: it is a .Net component built for work in COM-Interop, and therefore usable by the Navision context, that is COM.Now, from what I know about COM, MS DTC and .Net transactions, I thought the transaction could flow from Navision to my .Net Component: but this doesn't happen.
MatteoSp
I don't think the Transaction can flow from NAV to your component... I think it goes straight from NAV to SQL but I may be wrong.What exactly is your component trying to do? There may be a better solution than trying to hijack the transaction.
Rob Burke