Geeks With Blogs
Pradeep Loganathan Distributed

In .Net 1.1 it is possible to use the some of the services provided by System.EnterpriseServices without having to inherit from serviced component. For example of you want to use the transaction support functionality you could do this.

public void DoWork()

{

System.EnterpriseServices.ServiceConfig sc;

try

{

sc = new ServiceConfig();

sc.Transaction = TransactionOption.Required;

ServiceDomain.Enter(sc);

Work();

ContextUtil.SetComplete();

}

catch(Exception e)

{

Console.WriteLine(e.ToString());

ContextUtil.SetAbort();

}

finally

{

ServiceDomain.Leave();

}

}

 

private void Work()

{

//update databases

Console.WriteLine(ContextUtil.IsInTransaction.ToString());

Console.WriteLine(ContextUtil.TransactionId.ToString());

}

 

The ServiceConfig class specifies& configures the services that you would need. Here I am setting the transaction options of the serviceconfig class to ensure that I am in a transaction once I enter the domain.

Posted on Friday, February 3, 2006 3:44 AM Transactions | Back to top

Copyright © Pradeep Loganathan | Powered by: GeeksWithBlogs.net