Create a. Net class for the com Application

Source: Internet
Author: User

I. Prerequisites for the com callable class

1. Create a class library project

2. In. netCodeExplicitly defines an interface and implements it.
For the COM Client, implementing functions through interfaces has a great benefit.
When a CCW (COM callable packaging) is generated,. Net maintains the same interface as the previous version.
This helps prevent the COM Client from being damaged by changes to the. NET Server.

3. Any class visible to the COM Client must be declared as a public class.
The CCW creation tool only defines public-class-based types. The same rule applies to methods, properties, and events that will be used by the COM Client.

4. Set Project Properties
4.1 Application-> assembly information-> check "make assembly com-visible"
4.2 build-> check "register for com InterOP" [Check this option to generate a TLB file after compilation. If it is not released on the local machine, you do not need to check it.]

For. Net that contains classes that will be used by comProgramYou should also consider using the key pair signature. Microsoft calls this signature to an assembly with a strong name. Adding a strong name to the Assembly signature helps. Net ensure that the code in the Assembly has not been changed after the Assembly is published. Although unsigned assemblies can also be called by COM clients, signatures are required for all global assemblies (global assemblies will be shared by multiple clients ).

II. Use the. NET Framework SDK's Assembly registration tool (regasm) to create and register a Type Library. For example:
Regasm.exe client. Console. dll/TLB: client. Console. TLB

References:

Interoperability: Call the. NET Component (. NET development (general) technology from the COM ComponentArticle)
Http://msdn.microsoft.com/zh-cn/library/ms973800.aspx

Assembly registration tool (regasm.exe)
Http://msdn.microsoft.com/zh-cn/library/tzat5yw6.aspx

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.