In a 64-bit operating system, IIS reports the error of "trying to load a program with incorrect format ".

Source: Internet
Author: User
Tags support microsoft

Reason:When a 32-bit project is published in IIS In a 64-bit operating system, the error "the DLL on which the project depends cannot be read and the program in incorrect format is attempted to be loaded" is reported.

 

Cause:The communication between assemblies is either 64-bit or 32-bit. Hybrid editing is not allowed. Otherwise, the error "trying to load a program with incorrect format" may occur.

 

Solution:

[C/S]

Running the C/S program is relatively simple. You can explicitly specify it as x86 (the 64-bit system defaults to x64) when building the C/S program.

[B/S]

Running B/S is a little complicated. When creating a website, there are two situations.

A: A "project" is created. This process is the same as that of C/S.

B: The website is created. You only need to modify the IIS configuration.

I) "cscript % systemdrive %/inetpub/adminscripts/adsutil. vbs set w3svc/apppools/enable32bitapponwin64 1"

(If the value of enable32bitapponwin64 is 1, a 32-bit application can be run.) You can run this item once through the command line interface. (This command enables IIS to register a 32-bit. Net FW)

Ii) by default, 64-bit op registers 64-bit. NET Framework under IIS. Therefore, you must register a 32-bit. NET Framework.

C:/Windows/Microsoft. NET/framework/v2.0.50727> aspnet_regiis.exe-I

 

 

Appendix: 64-bit Windows IIS 32-bit and 64-bit conversion methods

 

The 64-bit version of IIS does not support Microsoft ole db provider for jet drivers. Therefore, if you want to use ASP or Asp.net to connect to access in 64-bit windows, you need to connect IIS in 32-Bit mode. The following is a method for converting between 32-bit IIS and 64-bit IIS on 64-bit systems of other websites.

ASP. NET 2.0, 32-bit
To run the 32-bit version of ASP. NET 2.0, follow these steps:
1. Click Start, click Run, type cmd, and click OK ".
2. type the following command to enable the 32-Bit mode:
Cscript % systemdrive %/inetpub/adminscripts/adsutil. vbs set w3svc/apppools/enable32bitapponwin64 1
3. type the following command to install ASP. NET 2.0 (32-bit) and install script ing in the IIS root directory:
% SystemRoot %/Microsoft. NET/framework/v2.0.50727/aspnet_regiis.exe-I
4. Make sure that the status of ASP. NET 2.0.40607 (32-bit) is enabled in the Web Service Extension list of Internet Information Service Manager.

ASP. NET 2.0, 64-bit
To run the 64-bit version of ASP. NET 2.0, follow these steps:
1. Click Start, click Run, type cmd, and click OK ".
2. type the following command to disable the 32-Bit mode:
Cscript % systemdrive %/inetpub/adminscripts/adsutil. vbs set w3svc/apppools/enable32bitapponwin64 0
3. type the following command to install ASP. NET 2.0 and install script ing in the IIS root directory:
% SystemRoot %/Microsoft. NET/framework64/v2.0.50727/aspnet_regiis.exe-I
4. Make sure that the ASP. Net 2.0.40607 status is set to allow in the Web Service Extension list of Internet Information Service Manager.
Note: The internal version of ASP. NET 2.0 may change as the internal version of the current release changes. These steps apply to the internal version 2.0.40607.

 

References:

Http://kitleer.blog.163.com/blog/static/9177857920102115045194/

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.