Run C # programs in x86 mode on Windows x64

Source: Internet
Author: User
Tags windows x64

All. net programs are platform-independent. The key is to check whether. Net VM supports the x64 platform. Ms has provided. Net x64. In vs, the. NET program is compiled into anycpu by default, so this is OK.

However, one of my C # programs calls the COM component of word2007 and calls some WIN32API. The problem arises. When running Windows 2003x64, the component whose clsin is {xxxxxx} in the com class factory fails to be retrieved because of the following error: 80040154.

The reason is very simple. The default value of C # program is anycpu. On x64, the program runs in 64-Bit mode. The 64-bit program cannot load 32-bit DLL. However, word2007 only has 32-bit DLL, so the call fails. The solution is very simple. It forces the C # program to be compiled into x86, so that the 32-bit Word 2007 dll can be loaded smoothly.

The modification method is as follows:

Set this compiler option in the Visual Studio development environment
  1. Open the properties page of the project.

  2. Click the generate property page.

  3. Modify the "Target Platform" attribute.

 

For more references, see the msdn http://msdn.microsoft.com/zh-cn/library/zekwfyz4.aspx

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.