Article : COM + Services Part 5 ( .NET Implementation Contd.)
Reply
![]() |
|
|
From:
Nasha
|
Hey Group,
Today we will create a client app for our COM+ component the different types of COM+ applications and how to implement JIT and ObjectPooling in them.
Registering our component and creating a client App:
Well All COM+ Components need to be registered with COM+ Services.But before that they need to be strong named hence we will create a strong name using strong name utility and sign all our assemblies with it.
a. Create a strong name key pair using sn -k "MyKey.snk" b. Sign your Serviced Assembly i.e. your Buss Layer and also all those, which are used by your Serviced Component c. Change the AssemblyInfo.cs and set the AssemblyKeyFile Attribute as follows [assembly: AssemblyKeyFile ("..\\..\\MyKey.snk")] and place the MyKey.snk in the project folder. d. Build the Solution Components will be registered on the local machines. e. To register the assembly on any other machine you can user regsvcs .. Check my blog on .Net framework Tools to know more about it.
Note:- If your COM Component is used by Managed Code then you dont need to register them explicitly with regscvs as the moment you call a function on the serviced component CLR will automatically register it with COM+. You need to register COM+ components explicitly only if they are being used by unmanaged code coz in that case regsvcs will create corresponding type library for it.
Lets us now create our cliient app.
a.Open a Windows or an ASP.NET application b. Add References to EmpEntity and Buss Layer DLLs. Also add reference to System.EnterpriseServices c. Add a button and write the following code to create the Employee entity and an Arraylist containing Skill entities. d. Pass the Employee entity to the EmployeeManager for updation.
private void button1_Click(object sender, System.EventArgs e) { EmpEntity.Employee emp = new EmpEntity.Employee(); emp.Skills = new ArrayList(); Skill skill; for(int i=0; i<10; i++) { skill = new Skill(); skill.Name = "Skill " + i; skill.TotalExpWithSkill = i; emp.Skills.Add(skill); } BussDLL.EmployeeManager empMgr = new BussDLL.EmployeeManager(); empMgr.UpdateEmployee(emp); }
Compile the project and run it.
Types of COM+ Components:-
There are two types of COM+ applications Library Application and Server Application.
Library Application: - Components of libaray application type are instantiated in client process i.e. there instantiation is done in the caller's process.
Server Application: - Server application components are instantiated in a serparate process this process is generally a surrogate process that is instantiated only for the components.
To set the type COM+ application can be done both from the MMC for COM+ Services and code. We will check out how to set it from code.
There is an attribute called ApplicationActivation you can use this to set the Activation type to either Library or Server. We need to add this to the AssemblyInfo.cs file
[assembly: ApplicationActivation(ActivationOption.Server)]
The ActivationOption can be either Server or Library.
Enabling ObjectPooling : -
To enable object pooling for .NET components we need to add ObjectPooling attribute to the class.
[ObjectPooling(Enabled=true, MinPoolSize=1,MaxPoolSize=10)]
You can even override the following methods to provide customization a.CanBePooled b.Activate c.Deactivate
Enable JIT: -
To enable JIT we need to add JustInTimeActivation Attribute to the class
[JustInTimeActivation(true)] Tomm we will checkout how to implement role based security in COM+ components. -- Please post your queries and comments for my articles in the user group for the benefit of all. I hope this step from my end is helpful to all of us. You can find all articles written by me at my personal blog http://spaces.msn.com/members/nasha.
Regards,
Namratha (Nasha)<o:p></o:p> |
|
View other groups in this category.
![]() |
To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings.
Need help? If you've forgotten your password, please go to Passport Member Services.
For other questions or feedback, go to our Contact Us page.
If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list.
Remove my e-mail address from dotNET User Group Hyd.
|
|