MSDTC error on vb.net HELP!

  • Thread starter Thread starter MarcoB
  • Start date Start date
M

MarcoB

I am trying to use Microsoft Distributed Processing and I am getting the
following error.

"There is no MTS objectcontext " I have SQL MSDTC loaded on my PC.

I have added the code below:
Any ideas ?? Tks.

------------------------------------
Imports System.EnterpriseServices

<Transaction(TransactionOption.Required)> _
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
ExecInTran()
End Sub

Public Function ExecInTran() As Boolean

Dim queueA As New MessageQueue()

Try
'step1: Do step DB stuff
'step2: DO MSMQ stuff
ContextUtil.SetComplete()
Return True
Catch ex As Exception
ContextUtil.SetAbort()
Return False

Finally
queueA.Close()
End Try

End Function

End Class
 
I would assume, you haven't created an object context before calling a
method on ContextUtil. You need to create a context before you access a
context.

If you aren't using components that are registered in COM+ applications but
you still want to use the services of COM+ (like transactions), then use the
COM+ 'Services Without Components' (SWC) feature. It works on Win2k3 and XP
SP2. Do this:

ServiceConfig config = new ServiceConfig(/* whatever settings you want */);
ServiceDomain.Enter(config);
// do stuff in a transaction...

ServiceDomain.Leave();

Look on MSDN for docs on:
Services Without Components (in COM+ SDK documentation)
System.EnterpriseServices.ServiceConfig (in .Net docs)
System.EnterpriseServices.ServiceDomain.(in .Net docs)

HTH
MikeDice [MSFT]
 
Back
Top