Well, how to make a. NET program in a 64-bit system that runs in 32-bit mode.

Source: Internet
Author: User

In fact, the simplest way is to set the platform to x86 on the solution.

But today, a third-party software is encountered, it calls a DLL is 32-bit, it may not have been tested in a 64-bit system run situation, it is compiled by default configuration set to any CPU.

However, when running in the default 64-bit mode on a 64-bit system, calling the 32-bit DLL will report an exception ...

So the idea is to let it in the 64-bit system, in 32-bit mode to run just fine ~

Search on the Internet, did not expect. NET itself provides this modification tool, called CorFlags.exe.

MSDN Documentation: https://msdn.microsoft.com/zh-cn/library/ms164699 (v=vs.110). aspx

This tool is typically installed with Visual Studio (actually part of the. NET SDK).

1, so open the "VS Developer Command Prompt" tool in the Start menu:

2. Directly enter CorFlags to use the tool (you can see the relevant Help content):

3, the first is to use corflags assembly file name command, without any parameters, you can use the tool to view information about the. NET Program:

It seems that the main is to see the PE there is PE32, and then 32bit[req] is 0, this seems to represent the current status of any CPU.

4. You can then use corflags assembly file name/32bit+ command, the main is to add the/32bit+ parameter, you can set the program to run in 32-bit mode:

Without any error, it should be success.

5, you can use the 3rd step of the command to check the results of the settings:

Yes, it's changed.

This time to run this program is running in 32-bit mode, and then load 32-bit DLL files will not be wrong ~

Good...

It doesn't seem like much use, does it?

Well, how to make a. NET program in a 64-bit system that runs in 32-bit mode.

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.