简体   繁体   English

无法加载文件或程序集“xxx”或其依赖项之一。 试图加载格式不正确的程序

[英]Could not load file or assembly 'xxx' or one of its dependencies. An attempt was made to load a program with an incorrect format

I just checked out a revision from Subversion to a new folder.我刚刚从 Subversion 检出了一个修订版到一个新文件夹。 Opened the solution and I get this when run:打开解决方案,我在运行时得到这个:

Could not load file or assembly 'xxxx' or one of its dependencies.无法加载文件或程序集“xxxx”或其依赖项之一。 An attempt was made to load a program with an incorrect format.试图加载格式不正确的程序。

This is the same code I had checked in a while ago.这是我不久前检查过的相同代码。 Why now is it doing this?为什么现在要这样做? I now also see a Debug x86 instead of just Debug in that xxx project's bin folder.我现在还在那个 xxx 项目的 bin 文件夹中看到了一个 Debug x86 而不仅仅是 Debug 。 What is Debug x86 and why don't I just have Debug only like I used to in the bin folder?什么是 Debug x86,为什么我不像以前那样在 bin 文件夹中使用 Debug 呢?

Sounds like one part of the project is being built for x86-only while the rest is being built for any CPU/x64.听起来项目的一部分是为仅 x86 构建的,而其余部分是为任何 CPU/x64 构建的。 This bit me, too.这也咬我。 Are you running an x64 (or uh... IA64)?您运行的是 x64(或呃……IA64)吗?

Check the project properties and make sure everything is being built for "Any CPU".检查项目属性并确保正在为“任何 CPU”构建所有内容。 f you're in Visual Studio, you can check for everything by going to the "x86" or "Any CPU" menu (next to the "Debug"/"Release" menu) on the toolbar at the top of the screen and clicking "Configuration Manager..."如果您在 Visual Studio 中,则可以通过转到屏幕顶部工具栏上的“x86”或“任何 CPU”菜单(在“调试”/“发布”菜单旁边)并单击来检查所有内容“配置管理器……”

If you get this error while running the site in IIS 7+ on 64bit servers, you may have assemblies that are 32bit and your application pool will have the option "Enable 32-Bit Applications" set to False;如果在 64 位服务器上的 IIS 7+ 中运行站点时遇到此错误,您可能有 32 位程序集,并且您的应用程序池将选项“启用 32 位应用程序”设置为 False; Set this to true and restart the site to get it working.将此设置为 true 并重新启动站点以使其正常工作。

I had this error when trying to use the dreadful Business Objects 4 for .Net SDK.我在尝试使用可怕的Business Objects 4 for .Net SDK 时遇到了这个错误。

They ship five BusinessObjects*.dll files, but all of them are 64-bit.他们提供了五个 BusinessObjects*.dll 文件,但都是 64 位的。

To get my webpage to load, I needed to click on Tools\\Options , then change this setting in VS2013:要加载我的网页,我需要单击Tools\\Options ,然后在 VS2013 中更改此设置:

在此处输入图片说明

inetmgr then come to Application pool->Advanced setting of your pool-> will have the option "Enable 32-Bit Applications" set to true; inetmgr 然后来到应用程序池-> 池的高级设置-> 将选项“启用 32 位应用程序”设置为 true; and restart IIS.并重新启动 IIS。 check again.!再检查一遍。!

The BadImageFormatException on an application running on IIS (not running from VS, since visual studio fixes the problem by using the build for "Any CPU") can be caused by the following:在 IIS 上运行的应用程序上的 BadImageFormatException(不是从 VS 运行,因为 Visual Studio 通过使用“任何 CPU”的构建修复了该问题)可能由以下原因引起:

The site is one a server that is x64 and the Application Pool's default setting for Enable 32-Bit Applications was False.该站点是一台 x64 服务器,应用程序池的启用 32 位应用程序的默认设置为 False。 and you have 32-bit assemblies你有 32 位程序集

On the level of Visual Studio, the fix is:在 Visual Studio 级别,修复是:

  1. Change the project setting "Target CPU" to "ANYCPU"将项目设置“Target CPU”更改为“ANYCPU”

Make sure you verify your setting for "Prefer 32-bit".确保您验证了“首选 32 位”的设置。 In my case Visual Studio 2012 had this setting checked by default.在我的情况下,Visual Studio 2012 默认检查了这个设置。 Trying to use anything from an external DLL failed until I unchecked "Prefer 32-bit" .尝试使用外部 DLL 中的任何内容都失败了,直到我取消选中 "Prefer 32-bit"

在此处输入图片说明

It's definitely an issue with some of the projects being built for x86 compatibility instead of any CPU.对于为 x86 兼容性而不是任何 CPU 构建的一些项目来说,这绝对是一个问题。 If I had to guess I would say that some of the references between your projects are probably referencing the dll's in some of the bin\\debug folders instead of being project references.如果我不得不猜测,我会说您的项目之间的某些引用可能引用了某些 bin\\debug 文件夹中的 dll,而不是项目引用。

When a project is compiled for x86 instead of 'Any CPU' the dll's go into the bin\\x86\\debug folder instead of bin\\debug (which is probably where your references are looking).当为 x86 而不是“任何 CPU”编译项目时,dll 将进入 bin\\x86\\debug 文件夹而不是 bin\\debug(这可能是您的参考资料所在的位置)。

But in any case, you should be using project references between your projects.但无论如何,您应该在项目之间使用项目引用。

if while In visual studio with IIS express working and when published failed try this:如果在 Visual Studio 中使用 IIS express 工作并且发布失败,请尝试以下操作: 在此处输入图片说明

In my case It worked by going to project Properties and under Target Framework i selected .NET Framework 4. This is because i have moved to a new machine that had other higher .NET frameworks already installed and the project selected them by default.在我的情况下,它通过转到项目属性并在目标框架下我选择了 .NET Framework 4 来工作。这是因为我已经转移到一台已经安装了其他更高版本的 .NET 框架的新机器,并且项目默认选择了它们。 See what target framework works for you.看看什么目标框架适合你。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载文件或程序集xxx或其依赖项之一。 试图加载格式错误的程序。 - Could not load file or assembly xxx or one of its dependencies. An attempt was made to load a program with an incorrect format. 无法加载文件或程序集“SharpSvn”或其依赖项之一。 尝试加载格式不正确的程序 - Could not load file or assembly 'SharpSvn' or one of its dependencies. An attempt was made to load a program with an incorrect format 无法加载文件或程序集“ MyLibrary”或其依赖项之一。 试图加载格式错误的程序 - Could not load file or assembly 'MyLibrary' or one of its dependencies. An attempt was made to load a program with an incorrect format BadImageFormatException 无法加载文件或程序集或其依赖项之一。 试图加载格式不正确的程序 - BadImageFormatException Could not load file or assembly or one of its dependencies. An attempt was made to load a program with an incorrect format 无法加载文件或程序集“ MWArray”或其依赖项之一。 试图加载格式错误的程序 - Could not load file or assembly 'MWArray' or one of its dependencies. An attempt was made to load a program with an incorrect format 无法加载文件或程序集“...”或其依赖项之一。 试图加载格式不正确的程序 - Could not load file or assembly '...' or one of its dependencies. An attempt was made to load a program with an incorrect format 无法加载文件或程序集“sapnco”或其依赖项之一。 试图加载格式不正确的程序 - Could not load file or assembly 'sapnco' or one of its dependencies. An attempt was made to load a program with an incorrect format 无法加载文件或程序集“Skybound.Gecko”或其依赖项之一。 尝试加载格式不正确的程序 - Could not load file or assembly 'Skybound.Gecko' or one of its dependencies. An attempt was made to load a program with an incorrect format 无法加载文件或程序集“ Oracle.DataAccess”或其依赖项之一。 试图加载格式错误的程序。 缓存 - Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format. Ncache 无法加载文件或程序集“ myApp.Web”或其依赖项之一。 试图加载格式错误的程序 - Could not load file or assembly 'myApp.Web' or one of its dependencies. An attempt was made to load a program with an incorrect format
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM