VB6 calls. Net DLL

Source: Internet
Author: User

CCW (COM callable wrapper) is a mechanism provided by vs2005. It can export. Net hosted DLL to a traditional com to facilitate VB6 and ASP calls. Below is a common example:
  • 1> Create a General C # class library project in vs2005 and write the code
//// Assume that the space is named cslib2 and the class name is class1 // the blue part is very important. // using system;
Using system. Collections. Generic;
Using system. text;
Using system. runtime. interopservices; namespace cslib2
{
[Classinterface (classinterfacetype. autodual)]
Public class class1
{
PublicInt add (int A, int B)
{
Return (A + B );
} PublicString mergestring (string a, string B)
{
Return (A + B );
}
}
}
  • 2> go to project --> "properties" --> "build" --> select"Register for com InterOP"
  • 3> modify [Assembly: comvisible (True)] // The default value is false.
  • 4> in Visual Studio 2005 command prompt command line tool, first enter the bin \ DEBUG directory of the project.Regasm cslib2.dll/TLB: cslib2.tlb generates the TLB file,Therefore, in VB6, you can select the TLB file in the form of COM.

 

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.