[Enterpriseservices] Using assembly to define how our components are registered in COM +

Source: Internet
Author: User
Organizer zheng yu @ ultrapower

Use the followingAssemblyDefine our components inCOM +In, where:

ApplicationnameAttribute is"COM +Directory"And"Component Service Management"TheCOM +ApplicationProgram.

[Assembly: applicationname ("mydll. Interface")]

DescriptionThe property is"COM +Directory"And"Component Service Management"ConsoleCOM +The application provides instructions.

[Assembly: Description ("My serviced component")]

ActivationoptionProperty indicates whether a component is activated in the caller's process. Here we willActivation. OptionSet to a server, that is, "The component will be activated in the dedicated server process ".

[Assembly: applicationactivation (activationoption. Server)]

ApplicationaccesscontrolSet the access management and verification level for the attribute. Here we set: Do not force access permission check for this application; The called authentication level is none; the simulated level is delegate.

[Assembly: applicationaccesscontrol (value =False,

Impersonationlevel = impersonationleveloption. Delegate,

Authentication = authenticationoption. None)]

CodeAfter the above definition is implemented, you can simply use

Regsvcs mydll. dll or register our COM + component through the following class definition. The call method is:

"String strcomplusdllfilepath = rootforumsdirectory + @" \ bin \ mydll. dll ";

Ultrapower. installclasslib. installclassregsvcs. Install (strcomplusdllfilepath );"

This saves a lot of trouble.

Namespace Ultrapower. installclasslib

{

Public   Class Installclassregsvcs

{

Public Installclassregsvcs ()

{

}


Install # Region Install

// --- Override the 'install' method.

Public   Static   Void Install ( String Strcomplusdllfilepath)

{

// --- Checkpoint

Trace. writeline ( String . Format ( " Register COM + component {0} " , Strcomplusdllfilepath ));



// --- Action

Process installprocess =   New Process ();

Processstartinfo installinfo =   New Processstartinfo ( " Regsvcs.exe " );

Installinfo. Arguments =   "   "   + Strcomplusdllfilepath;

Installinfo. windowstyle = Processwindowstyle. hidden;

Installprocess. startinfo = Installinfo;


// Run

Installprocess. Start ();

Installprocess. waitforexit ();



}

# Endregion


}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.