Compile a 32-bit DLL file in a 64-bit Development Environment

Source: Internet
Author: User


Recently, when I was working on the pH project, I encountered a small problem. Our system is a secondary development based on people: we use their devices and need them to provide us with interfaces. When we get the interface, compilation on a 32-bit system won't go wrong, while compilation on my 64-bit system always prompts an error:


Call DLL to try to load programs with incorrect format. (Exception from hresult: 0x8007000b)

I first thought about finding a new DLL file on the Internet, that is, the DLL file in a 64-bit system, and then registering it. Fortunately, there are two folders, x86 and x64. X86 contains a DLL file, but x64 is empty. I was speechless, and then I went online to find DLL files and register them one by one. After a long time, I was not successful.

The problem is obvious, that is, the problem of compiling 32-bit DLL in my 64-bit development environment. Today I changed my mind: How to Make It compiled successfully. The problem is easily solved.


Open vs, select the solution for your project, right-click and select Properties (or Alt + enter), open the generate tab, and change the target platform to x86, the compiled DLL is a 32-bit DLL. At the same time, if your program contains code about pointers, an error is usually reported, causing you to fail to compile the program. You need to select "allow unsafe code option" on this tab ".



After solving the problem, I realized that the problem was so simple. At the same time, I felt that although vs had been used for a long time, the vsplatform could not be used.


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.