COM + was already generated as early as the window2000 was released and integrated into the operating system,
The runtime is in the form of a service. COM + adds a series of MTS (a system service that
Used to manage persistent data in a database and also to handle persistent message queues and file systems in transactions
Service
1, transaction services: It ensures the integrity of the data in the distributed system.
2. Security services: Its security model provides a way to handle security without writing any code.
3. Synchronous services: Provides a way to manage concurrency problems in components without writing code
。
4. Resource management: (including Resource manager and resource allocator) Manage database connections, network connections, and
Memory, and so on.
5, JIT activation: That is (Just in time) is inherited from MTS a service, when the customer calls to
Keeps an instance of this object active and cached in server memory, and when you finish using the object, you
Notifies the MTS environment that the resource occupied by the object, such as a database connection, can be freed.
6, Object pool: To provide a line pool store ready-made objects for the next reuse, is a system of
Automatic service. When an application accesses a COM + component, an instance of the component is created for the application
and stored in the object pool, the application is closed after the instance is destroyed, you can freely configure the component to make its instance
The state in the pool enables the reuse of the instance and improves the performance and scalability of the application.
7, role-based Security: This is easy to understand, that is, verify the role, give security permission, to different
Households are given different privileges.
8. Queue component (MSMQ): Provides asynchronous Message Queuing to automatically convert data to a number in its form
According to the package.
9. Shared Property Manager (SPM): Used to manage object state information stored in memory, in a service
Can be used to share the state between multiple objects within a process and provide concurrent processing.
10. Compensation Resource Manager (CRM): Used to generate log files during transaction processing and to handle the system
Collapse. Includes the CRM worker (is the main part of CRM, the interface provided through the CRM infrastructure conceal
The relevant information is written to the log, and the log file is retrieved when required, and the CRM compensator (used in the transaction
When completed, the transaction and generated log files are submitted to the user performing the transaction.
11, Concurrency: That is, allow multiple processes in one application to run simultaneously, the process is divided into groups of contexts
(A collection of objects with the same requirements) is contained in a unit (a set of contexts within a process), one in
A process can contain multiple contexts, involving objects of different requirements, and each context has a unique
COM object to provide services such as COM + transaction processing and JIT activation.
Use COM +-provided tools to create multi-tier applications that perform transactions, and to handle thread allocation
The problem. OK, after introducing COM + 's features, you can then describe the COM + type.
COM + has several different types of uses:
1. Application Agent: A file that contains application registration information, that is, when a client accesses a remote computer
Server program, the application agent running on the client will write the information about the server application
into the client computer.
2. Server application: The COM + application executes within the process of the COM + application itself, while
Use concurrency to process components.
3, the Library application: is in the client application process execution, loading in the client application process
, using task-based security, the disadvantage is that remote access and queue components are not supported.
4. COM + Pre-installation application: Into the COM + application folder in Component Services in Administrative Tools
View to see what is a COM + preinstallation application, which is automatically installed in a group during COM + installation
Piece Service Application, cannot be modified or deleted.
It also involves a concept called "Assembly (Assembly)": It is a CLR of all types and its
A collection of its resources, such as bitmap files. The configuration is available through the administrative tools. NET Framework to view the
。 Includes assemblies that have private and shared.
Private assembly: It is accessible only to applications that have the same path as the assembly. Default is Private,
Must be placed in the folder of the application that uses it.
Shared assembly: An assembly that is added to the GAC (Global Assembly Cache). The GAC is specifically
Used to hold assemblies so that applications can share them, one thing to be aware of is to save
Assemblies placed in the GAC must have a unique name that can be passed through the. NET Command Execution window hit
Enter Sn-k assemblyname.snk to generate a unique name, called a strong name, that generates a strong name
, a public key is appended to this Assembly to prevent the risk of being replaced by a similar name.
. NET provides two mechanisms for the security of an assembly: one is the strong name mentioned earlier, a
is to use signcode, which is understandable as a digital signature. Signcode.exe is used to mark an assembly, while
Embedding a digital signature into an assembly allows the user to identify the developer who created the assembly.
(Note: In the GAC, you cannot have two strong names of the same name, otherwise it is not a strong name, but you can store multiple copies of one assembly and the assembly in the GAC can only be deleted by a user with certain permissions)
About assembly version number: Each version has a 128-bit version number, expressed as four
Min: Major (the main version number, the project changes when the change). Minor (add a feature to the project to change
Change). Build.revision (the latter two are automatically updated), these version information can be passed in the application
The AssemblyInfo.cs file in the program to view.
It's a bunch of theories, here's how COM + applies:
Components that use COM + services in. NET are called. NET service components, unlike general components, differ in
The former uses COM + services. Use. NET service component is designed to enable access to COM + uniforms
Some of the basic classes such as ServicedComponent and Automatic Yi angry left Sanyu
Aspects and so on.
In use. NET service components must be registered before service components, there are three ways:
1, Manual registration: Through the RegSvcs.exe command line tool to register, such as: RegSvcs
After Yourcomponent.dll, a yourcomponent.tlb type library is generated, containing the object's
Type information (Note that you must first register a yourcomponent strong name before using this command)
2, Programming Registration: The use of registrationhelper classes, mainly in the use of
Iregistrationhelper the method in the interface.
3, Dynamic registration: Refers to the implementation of the application process, check the version of the installation components, such as components of the positive
If the version is not installed, the required version is automatically installed at run time, that is, autoenrollment. (Note: calling Automatic
The registered user must be a member of the WINDOW2000 Administrative group because dynamic registration has no
method to change the COM + catalog, otherwise the registration process fails)
OK, finally finished, and then look at the example:
----------------------------------------------------------------------------------------------------------
Using System;
Using System.EnterpriseServices; Name space that must be introduced
Using System.Reflection; Name space that must be introduced
Using System.Windows.Forms;
[Assembly:applicationname ("Calcomp")]
[Assembly:assemblykeyfileattribute ("Calcomp.snk")]//must first register a strong name called Calcomp.snk, while commenting out the AssemblyInfo.cs file in the project. Assembly:assemblykeyfileattribute ("")], otherwise the definition is repeated.
Namespace Calcomp
{
public interface icommission
{
void Commissioncal (string Name,int salesamt);
}
public class Calcomp:servicedcomponent,icommission//Inheritance ServicedComponent make it a serviced component
{
public void Commissioncal (String name,int salesamt)
{
double comm;
//string msgstring;
if (salesamt>=50000)
{
comm=salesamt* 0.10;
messagebox.show (comm. ToString (), "Presto Systems");
if (salesamt<50000)
{
comm=salesamt*0.05;
messagebox.show (comm. ToString (), "Presto Systems");
}
}
}
}
OK, okay, here's how to call this service component
--------------------------------------------------------------------------------------------------------------- ---
Using System;
Namespace Calclient
{
Class Calculate
{
static void Main (string[] args)
{
Calcomp.calcomp c=new Calcomp.calcomp ();
Console.WriteLine ("Please input the employeer name");
String Name=console.readline ();
Console.WriteLine ("Please input the Salesamt");
String Salesamt=console.readline ();
C.commissioncal (Name,int. Parse (Salesamt));
}
}
}
(Note: To add a reference to a project reference that references the DLL generated by the service component above before using the service component)
--------------------------------------------------------------------------------------------------------------- -
There are a lot of features about COM + serviced components, and this little article just uses one of the feathers.