Visual Studio 64-bit application Compilation

Source: Internet
Author: User

The platform under Visual Studio compilation option build contains x64, any CPU, and x86. X86 indicates that it can only run in a 32-bit environment, x64 indicates that it can only run in a 64-bit environment, and any CPU indicates that your Assembly can adapt to 32-bit or 64-bit environment changes, however, if your Assembly depends on an Assembly compiled with the x86 option, which of the following statements can only be used for compiling your Assembly, rather than any CPU compilation? If any CPU is used for compiling, the following error occurs during running:

Unhandled exception: system. badimageformatexception: cocould not load file or ASSE
Using y' sourcecode. hostclientapi, version = 4.0.0.0, culture = neutral, publickeytoken
= 16a2c5aaaa1b130d' or one of its Dependencies. An attempt was made to load a pro
Gram with an incorrect format.
File Name: 'sourcecode. hostclientapi, version = 4.0.0.0, culture = neutral, publicke
Ytoken = 16a2c5aaaa1b130d'

The reason is that if any CPU is used for compilation, the default running on 64-bit machines is 64-bit. Generally, 10 Assembly needs to call a 32 com library, as long as x86 compilation is used, the program is a 32-bit program that runs on the 64-bit system by running wow64. Therefore, if the Assembly needs to use the Win32 library, you must note that the default any CPU cannot be used in the compilation option.

If your Assembly has an Assembly compiled by calling VC ++, if Microsoft Visual C ++ 2005/2008/SP1 redistributable package (x86) update package is not installed, a similar error may occur:

 

Unhandled exception: system. Io. fileloadexception: cocould not load file or assembl

Y' sourcecode. hostclientapi, version = 4.0.0.0, culture = neutral, publickeytoken = 16

A2c5aaaa1b130d' or one of its Dependencies. The application has failed to start

Because its side-by-side configuration is incorrect. Please see the application

Event Log or use the command-line sxstrace.exe tool for more detail. (exception

From hresult: 0x800736b1)

File Name: 'sourcecode. hostclientapi, version = 4.0.0.0, culture = neutral, publicke

Ytoken = 16a2c5aaaa1b130d '---> system. runtime. interopservices. comexception (0x800

736b1): The application has failed to start because its side-by-side venture ATI

On is incorrect. Please see the Application Event Log or use the command-line SX

Strace.exe tool for more detail. (exception from hresult: 0x800736b1)

The specific use of Microsoft Visual C ++ redistributable package versions 2008, SP1 depends on the version of Visual Studio used by your applications.

Microsoft Visual C ++ 2008 SP1 redistributable package (x86 ).

The above problem occurs in my summary of the problems I encountered when I was preparing to deploy the application on Windows Server 2008 R2 server core. It took nearly one day, we hope to help students who encounter similar problems in the future and save more time.

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.