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
}
}