.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?
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;
}
}
}
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
{
...
}