An attempt was made to load a program that is not properly formatted. (Exception from hresult:0x8007000b)

Source: Internet
Author: User

Two different reasons :

The first is that the running of the program does not match the number of platform system bits, the second one is the Damned vs whole ...

Typically occurs under the following three scenarios.

C # calls 32-bit C + + *.dll on a 1.64-bit system

When IIS publishes an *.dll application that contains 32-bit on a 2.64-bit system

Writing C + + *.dll on a 3.64-bit system, calling through C # on a 64-bit system, may or may not succeed, and failure is reported as BadImageFormatException exception, and it is also the second most likely case. It's the fucking vs.

Here's how to fix it:

1.vs under the 64-bit system, when compiling debugging a C + + API, Error: Unhandled badimageformatexception attempted to load a program that is not properly formatted. (Exception from hresult:0x8007000b)

See:

The reason for this is that the API was developed under the three-bit system, and in the development of the system, the built target platform needs to be set to X86.

the method is :

in Solution Explorer on the right, right-click on the item's properties. In the Properties window, select "Build"--"target platform" dropdown to select "X86". See:

and then save the recompile

Cause: the communication between assemblies is either full of 64-bit environments or full of 32-bit environments. cannot be mixed access. Otherwise, the error "attempting to load an improperly formatted program" will appear;

The solution is to turn on 32-bit compatibility for the program pool of the publishing site , such as:

3. if the above is not resolved , that is the problem with C # Engineering in VS , open the corresponding project file (*. Csproj), such as the <Prefer32Bit>false</Prefer32Bit> node

The following is an explanation of MSDN :

Csharpprojectconfigurationproperties6.prefer32bit Property

Gets or sets a flag that indicates whether the preferred 32-bit platform.

Namespaces: VSLangProj110

Assembly: VSLangProj110(in VSLangProj110.dll )

Grammar

C#

BOOL Prefer32bit {get; set;}

Property value

Type: System.Boolean

Returns a flag that represents a 32-bit preference. Returns True if 32 bits is preferred. Otherwise, returns false.  

An attempt was made to load a program that is not properly formatted. (Exception from hresult:0x8007000b)

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.