I want to create a 64-bit ASP.NET MVC 2 web application and reference it with a 64-bit class library. But in doing so, I get a "System.BadImageFormatException" -Exception
Each project / solution that I add is .Net 4.0:
- I am creating a new empty solution called "MySolution"
- I am adding a new project to this solution (ASP.NET MVC 2 web application) called "MyMvcApplication", without a test module to simplify its work (Visual Studio asks to create it)
Up to this point, "MyMvcApplication" works as it should. Even when setting up on x64.
- I am adding a new project to soltion (Class Library) called "MyClassLibrary"
- I install "MyMvcApplication" as the initial project (it should already be, but only for a complete list of what I'm doing).
- I go to the Build / Configuration Manager menu, create a new "x64" platform, copying it from "Any CPU". Then I installed both projects on x64.
- I now have Debug | x64 and for "MyClassLibrary" and "MyMvcApplication" a platform was added for the x64 platform and the "Build box".
- I am adding a link from "MyMvcApplication" to "MyClassLibrary" (add the link, go to the "Projects" tab and select "MyClassLibrary").
I run "MyMvcApplication" and get the following error:
Could not load file or assembly 'MyClassLibrary' or one of its dependencies.
An attempt was made to load a program with an incorrect format.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.BadImageFormatException: Could not load file or assembly
'MyClassLibrary' or one of its dependencies. An attempt was made to load a program
with an incorrect format.
Source Error:
An unhandled exception was generated during the execution of the current web request.
Information regarding the origin and location of the exception can be identified
using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'MyClassLibrary' could not be loaded.
=== Pre-bind state information ===
LOG: User = Dev\Chris
LOG: DisplayName = MyClassLibrary
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: MyClassLibrary | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///c:/Test/MySolution/MyMvcApplication/
LOG: Initial PrivatePath = c:\Test\MySolution\MyMvcApplication\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: c:\Test\MySolution\MyMvcApplication\web.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/f962adb4/1764faec/MyClassLibrary.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/f962adb4/1764faec/MyClassLibrary/MyClassLibrary.DLL.
LOG: Attempting download of new URL file:///c:/Test/MySolution/MyMvcApplication/bin/MyClassLibrary.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
EDIT:
running "corflags c: \ Test \ MySolution \ MyMvcApplication \ bin \ MyClassLibrary.DLL", as suggested from bobbymcr on the visual studio command line, I get:
Version : v4.0.30319
CLR Header: 2.5
PE : PE32+
CorFlags : 1
ILONLY : 1
32BIT : 0
Signed : 0
, : - (
EDIT2:
x86 - ASP.NET MVC 2 :
Parser Error
Description: An error occurred during the parsing of a resource required to service this
request. Please review the following specific parse error details and modify your
source file appropriately.
Parser Error Message: Could not load type 'MyMvcApplication.MvcApplication'.
Source Error:
Line 1: <%@ Application Codebehind="Global.asax.cs"
Inherits="MyMvcApplication.MvcApplication" Language="C#" %>
Source File: /global.asax Line: 1
, , , x86 x64.
?