.NET COM+ - "Error when enlisting in a distributed transaction"

Hi,

I developed a .NET serviced component with Framework .NET 1.1, instaled it in a win2k SP4 server (COM+ 1.0) and marked that component with Transactions=Required. This application server communicates with a SQL Server 2000 SP3 database server inside the same subnet/domain. When a simple select query is run under the .NET Serviced component, i got the message:

"Error when enlisting in a distributed transaction"

The COM+ package that hosts this component has an ActivationOption=Library and has the options "Enforce Access Checks for this Application" and "Enable Authentication" marked as false.

The component is created from a ASP.NET webform using ASPNET user credentials ... this user is a member of the administrators group only for testing purposes.

Could someone tell me what's wrong?

[866 byte] By [SamuelNakano] at [2008-2-13]
# 1
Is there any further information in the Windows Event Log?
# 2

no ... nothing in application, security or system logs ...

SamuelNakano at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Transactions Programming...
# 3
  1. First try disabling "Access Checks for this Application", and see whether it works
  2. If you Change Transactions to "Join" (I can't remember the exact name, but the one where it joins if there's an active transaction, but doesn't start a transaction if there isn't already one), and try it, does it work?
  3. When you debug the code, what line does it fail on?
# 4

(1)I have already disabled the "Access checks for this application" and it doesn't work.

(2) "Join" ?

(3) It fails on the line where the sqlconnection runs the simple select query i mentioned.

SamuelNakano at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Transactions Programming...
# 5
(2) - The option I was looking for was "Supported". Try both Supported and NonSupported.
# 6
  1. Are you using the AutoComplete attribute, or are you using the ContextUtil class?
  2. If you comment out all COM+ attributes/references, does your query/transaction execute successfully?
  3. Are there other COM+ components that you have written (either in the same application, or on other applications on the same dev box) that have worked?
# 7

Hi Christopher,

I must use Transactions=Required because the component is the root transation, but i've tried with Transactions=Disabled and Supported and it works, because the MSDTC doesn't initiates the distributed transaction context for the call.

Asnwering your questions:

(1) I'm using the ContextUtil class, and all methods doesn't have the [Autocomplete] attribute.

(2) Yes. But i told you, this is not the case, it must be run under MSDTC.

(3) There is no other application written this way

Sample code:

public interface ITest
{
int TestMethod();
}

[Transactions( TransactionOption.Required )]
public class test: ServicedComponent, Itest
{
public int TestMethod()
{
try
{
// Do the select query (error in this line)
ContextUtil.SetComplete();
}
catch
{
ContextUtil.SetAbort();
throw;
}
}
}

SamuelNakano at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Transactions Programming...
# 8
Just one thing I remember from a while ago that may help. Try using the GUID utility to create a GUID (In VS.NET: Tools -> Create GUID) for each class, and then mark them as such:

[ComVisible(true)]
[Transactions( TransactionOption.Required )]
[Guid("8D92585E-C128-4bb4-A131-61E84E9D9500")]

public class test: ServicedComponent, Itest
{

...
}

# 9

Hi Samuel,

Can you also say what OS is hosting the SQL Server database?

Thanks.

FlorinLazar-MSFT at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Transactions Programming...
# 10
Florin - I like your signature!
# 11

Hi Florin,

The OS hosting the SQL Server database is a Win2k SP4 server.

Are you aware of any specific security settings necessary for the MSDTC to work on this scenario?

SamuelNakano at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Transactions Programming...
# 12

Many things can lead to the error you are getting: http://blogs.msdn.com/florinlazar/archive/2005/09/16/469064.aspx

The most common issue is the inability to ping the machines uses their netbios names (computer names). Can you try this test?

FlorinLazar-MSFT at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Transactions Programming...

Software Development for Windows Vista

Site Classified