Program to register classes in. Net Assembly into COM classes
Recently, you need to right-click IE to add a custom menu item in the context menu and respond to it.
Therefore, you must register. Net Assembly as a COM class.
Of course, manual use of a series of command lines can be achieved:
See QuickStart interactive operations> Generate. net com servers that can be called from the COM Client:
Http: // localhost/quickstart/howto/doc/Interop/Building_Samples_COM2NET.aspx
Of course, it is difficult to use Process to call tlbexp.exe‑gacutil.exe‑regasm.exe and other command line implementations!
In fact, there is a simpler method, which can be done in two sentences:
System. incluiseservices. Internal. Publish P = new System. incluiseservices. Internal. Publish ();
// P. GacInstall (asmFile );
P. RegisterAssembly (asmFile );
System. Windows. Forms. MessageBox. Show ("OK ");
The download contains a complete set of Solution:
Http://files.cnblogs.com/Microshaoft/RegAsm2Com.rar
1. Asm4ComApplication: an application to be installed
2. RegAsm2ComInstaller: it is a console application that contains a Custom installation program class (Custom Action Installer ).
3. Setup1: the installation project used to install Asm4ComApplication
The Setup provides the following functions:
1. Register. Net Assembly as a COM class
(In addition, the Setup installation project:
"Application folder"-> "File Installation properties"-> "Register" [vsdraCOM, vsdraCOMRelativePath]
You can also register. Net Assembly directly into a COM class during installation without programming)
2. Right-click IE to add a custom menu item (Microshaoft displays Img Src Url) and respond