I,. NetCallComComponents
. NetCallComThere are two main types of components: static call and dynamic call.
Static call:Tlbimp.exeName generationComComponent in. NetEnvironment, and then accessComComponent.
The so-called dynamic call: does not passComComponent packaging classComThe component is called, but is carried out through reflection in the remote line.ComComponent call.
The two implementation methods are discussed in detail below:
<! -- [If! SupportLists] --> 2.<! -- [Endif] --> Static call
<! -- [If! SupportLists] -->1,<! -- [Endif] -->WriteComComponentsMyComponent. dll
<! -- [If! SupportLists] -->2,<! -- [Endif] -->Generate accessibleComPackage of components:
Tlbimp/out: Interop. MyComponent. dll MyComponent. dll
<! -- [If! SupportLists] -->3,<! -- [Endif] -->In. NetAccess in code
You only need to addComPackaging class, just like accessing. NetSame as accessoriesComComponent.
Of course, the above three steps can also be found inVSAddComComponent reference, letVSThe second step is automatically completed.
Note:
<! -- [If! SupportLists] -->1,<! -- [Endif] -->If you referenceComComponent. NetThe project is named as a strongly-named component.ComThe packaging class of the component must also be a strongly-named component. Therefore, you must manually perform the second step and setSnkFile name. The procedure is as follows:
Tblimp/keyfile: filename. snk/out: Interop. MyComponent. dll MyComponent. dll
<! -- [If! SupportLists] -->2,<! -- [Endif] -->For more settings, seeTlbimp.
<! -- [If! SupportLists] --> 2.<! -- [Endif] --> Dynamic call
<! -- [If! SupportLists] -->1,<! -- [Endif] -->WriteComComponentsMyComponent. dll.
<! -- [If! SupportLists] -->2,<! -- [Endif] -->In. NetThe program generatesCom