Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: RE: Are .NET Component Dlls MTS Enabled....


Message #1 by =?iso-8859-1?Q?Fredrik_Norm=E9n?= <fredrik.normen@e...> on Tue, 2 Jan 2001 09:14:33 +0100
You have to use the RegAsm.exe or RegSvcs.exe to register .Net components.

This tools will genereate, registering and installing the type library into

the registry or an existing COM+ application.



/Fredrik Normén





-----Original Message-----

From: Krishnakant Baderia [mailto:krishnabaderia@s...]

Sent: den 29 december 2000 07:49

To: ASP+

Subject: [aspx] Are .NET Component Dlls MTS Enabled....







hi all,



Can any body tell me about the MTS support of the .NET Components made in VB

.NET ??



I have made a Namespace, compiled it through VB .NET. I could call it into

my VB .NET Client. Its working fine.



Now I want the component to run under Component Services ie MTS. But when I

try to add, I get a error telling "One or more files doesnot contain

Component or Type Libraries. These files cannot be installed."



Can any body tell me why this happens.



Krishna Kant Baderia

Sr. Developer

Solutions Infosystems Pvt. Ltd.

www.Solutionsny.com



Phone : (O) +xx-xx-xxxxxxx

           (R) +xx-xx-xxxxxxx / xxxxxxx













---

http://www.asptoday.com - the leading site for timely,

in-depth information for ASP developers everywhere.

---

You are currently subscribed to aspx as: $subst('Recip.EmailAddr')

To unsubscribe send a blank email to leave-aspx-$subst('Recip.MemberIDChar')@p2p.wrox.com

Message #2 by Scott Guthrie <scottgu@m...> on Sun, 7 Jan 2001 20:51:33 -0800
Reposting from a post I did on the ASPNGBeta listserv

(http://www.asplists.com/asplists/aspngbeta.asp) in case some people aren't

on it.



Thanks,



Scott



------------------------



Several people have posted questions asking "is COM+ dead", "how does COM+

relate to .NET", etc.  The answer is that COM+ is definitely *not* gone.  It

remains and will continue to be an important part of the overall programming

model -- and can be fully leveraged from ASP.NET and the overall .NET

Framework.  You can continue to create COM+ components using VS6 and other

compilers and then call them from ASP.NET pages.  You can also take

advantage of COM+ services with new classes built using the .NET Framework.



You will find that leveraging these services (for example: COM+ transactions

and COM+ object pooling) has become a whole lot easier using ASP.NET and the

.NET Framework.  For example, it is now possible to avoid having to manually

install a transacted component using the COM+ Component Services

Administration tool.  Instead, if you want a component to support

transactions, you can simply add a "Transaction" attribute to the top of a

class and copy the compiled component into the "bin" directory of your

ASP.NET web application.  When the class is first activated -- it will

automatically be registered with COM+ for you (which means "xcopy

deployment" of both non-transacted and transacted components).  



You can also now take advantage of the COM+ "AutoComplete" feature within

your .NET components simply by marking activating methods within an

"AutoComplete" attribute.  Assuming no exceptions get thrown during the

method's execution -- the transaction will automatically commit for you.  If

you want to force termination of a transaction, simply raise or throw an

exeception to abort it.



The below sample demonstrates how to build a simple transacted C# class and

use it within an ASP.NET page written using VB (note that I've only tried

this on Win2k -- I'm not sure whether this works on NT4 in beta1):



----------------------------------------------------------------------

Account.cs:

----------------------------------------------------------------------



using System;

using Microsoft.ComServices;



// COM+ app name as it appears in the COM+ catalog

[assembly: ApplicationName("TestApp")]



[Transaction(TransactionOption.Required)]

public class Account : ServicedComponent 

{

  [AutoComplete]

  public String Debit(int amount) 

  {

     // Todo: Do some Database work, throw an exception to abort the 

     // transaction -- otherwise the transaction will commit



     // Use the ContextUtil class to return the transaction id

     return ContextUtil.TransactionId.ToString();

  }

}



----------------------------------------------------------------------



To compile the above class, simply execute the following code within the

root directory of an ASP.NET application:



   mkdir bin

   csc /target:library /out:bin\Account.dll Account.cs

/r:Microsoft.ComServices.dll



then invoke the component from the following ASP.NET Page (no registration

required):



----------------------------------------------------------------------

Trans.aspx:

----------------------------------------------------------------------



<html>



   <script language="VB" runat=server>



      Sub Page_Load(Sender As Object, E as EventArgs)



         Dim MyAccount as New Account()

         TransId.Text = MyAccount.Debit(343)



      End Sub



   </script>



   <body>



       <h1>C# Transacted Component within ASP.NET</h1>



       <b> Transaction ID: </b> <asp:label id="TransId" runat=server/>



   </body>



</html>



----------------------------------------------------------------------



The transaction id of the completed transaction should be rendered cleanly

into the output.  To see how the COM+ auto-registration mechanism worked,

open up the "Component Services" admin tool within the

"Programs->Administrative Tools" item on the Start Menu.  Expand the

"Component Services" tab to "Computers->My Computer" and then to "COM+

Applications".



Notice the precense of the "TestApp" COM+ Application/Package.  This was

created in response to line 4 of the Account.cs file (which had an assembly

attribute indicating the COM+ App name to create).  Expand this to see the

"Account" component listed within it.  Notice that the properties of the

component (for example: transaction=required) within the admin tool match

those set within the Account.cs file.



Then click on the "Distributed Transaction Coordinator->Transaction

Statistics" item within the admin tool.  Notice that the transaction count

increases each time you hit the page.



----------------------------------------------------------------------



Note that the above sample demonstrates calling a transacted component from

a non-transacted ASP.NET Page.  Note that if you want the ASP.NET page

itself to be transacted as well (for example: if you were calling multiple

transacted components from it and wanted them to all share the same

transaction), simply add the <%@ Page Transaction="Required" %> attribute to

the top of the file.



Thanks,



Scott









---

http://www.asptoday.com - the leading site for timely,

in-depth information for ASP developers everywhere.

---

You are currently subscribed to aspx as: $subst('Recip.EmailAddr')

To unsubscribe send a blank email to leave-aspx-$subst('Recip.MemberIDChar')@p2p.wrox.com


  Return to Index