Could not load assembly error when changing to x64

2020-07-16 09:18发布

I have just created a new asp.net 3.5 web application. I went to the application property and changed the platform target to x64. I didn't write any code and i have not changed anything. Next i hit start debugging in Visual Studio. The following error occured:

Could not load file or assembly "SOLUTION NAME", Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Any one have an idea how to solve this?
Thanks.

Edit:
I have these warnings:

Warning 1 Assembly generation -- Referenced assembly 'System.EnterpriseServices.dll' targets a different processor
Warning 2 Assembly generation -- Referenced assembly 'mscorlib.dll' targets a different processor
Warning 3 Assembly generation -- Referenced assembly 'System.Web.dll' targets a different processor
Warning 4 Assembly generation -- Referenced assembly 'System.Data.dll' targets a different processor

Configuration manager:

enter image description here

6条回答
该账号已被封号
2楼-- · 2020-07-16 09:45

If you start your app just using F5 or Start button, and you debug on IIS, could be this:

Debug -> Options -> Projects and Solutions -> Web Projects. And select "Use the 64 bit version of IIS Express for web sites and projects".

查看更多
女痞
3楼-- · 2020-07-16 09:50

Please check your references in the solution.Probably that is pointing to the old dlls.

查看更多
放我归山
4楼-- · 2020-07-16 09:55

Its likely to be a 32bit dll that is referenced.

If you are debugging on IIS, open the advanced settings of the application pool and make sure 'Enable 32 Bit Applications' is enabled. That has sorted the issue for a number of times.

查看更多
淡お忘
5楼-- · 2020-07-16 10:02

I have found the problem.

It seems that Visual Studio and Cassini run as 32-bit applications. If i try to host my 64-bit ASP.NET application using Microsoft's Cassini, i will get an exception.

So i deployed my solution on IIS, changed it to 64-bit, debugged it and every thing is working perfectly.

查看更多
6楼-- · 2020-07-16 10:02

In addition on what @winSharp93 says, have a look at the Application Pool Advanced Settings and ensure "Enable 32 Bit applications" is set to false.

查看更多
干净又极端
7楼-- · 2020-07-16 10:03

Ensure that all dlls you compile are for 'any cpu' or are compiled for 'x64'. You can find this on the project settings window for each project.

查看更多
登录 后发表回答