Com and. Net interoperability

Source: Internet
Author: User

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

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.