How to invoke a DLL written in C # in MFC

Source: Internet
Author: User

Compiling an MFC executable file or a rule DLL using/clr

1, open the Project Properties dialog box by right-clicking the project in Solution Explorer and choosing Properties.

2, expand the node next to Configuration properties and select General. In the right-hand pane, under Project defaults, set common language runtime support to common language runtime support (/clr).

3. In the same pane, make sure that MFC is set to use MFC in shared DLLs.

4. Under Configuration Properties, expand the node next to "C + +" and select "General". Make sure that debug Information format is set to program database/ZI (instead of "/zi").

5. Under Configuration Properties, select "C + +" and select "code Generation". Make sure that the Run-time library is set to one of the multithreaded debug DLLs (/MDD) or multithreaded DLLs (/MD).

Second, in the code to reference the required DLL

#using <mscorlib.dll>

#using "DownloaFiles.dll"//Replace with required DLL file

using namespace System;

Using namespace admessage_test;//to the namespace used by classes in the DLL

Add #pragma managed before the DLL function calls the code

This is a manage and unmanage hybrid programming under MFC is a way to achieve.

Related Article

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.