相关疑难解决方法(0)

"即使平台相同,也试图加载格式不正确的程序"

我在64位系统上调用32位非托管DLL的函数.我得到的是:

BadImageFormatException:尝试加载格式不正确的程序.(HRESULT异常:0x8007000B)

起初,我将我的项目设置为Any CPU平台,因此我将它们都更改为x86,但此错误仍在发生.这真的是我所知道的唯一解决方案.

DLL没有损坏或任何东西,因为我可以将它们与其他程序一起使用(我没有源代码).我想也许它没有找到依赖,但我检查了,他们都在那里.另外,DllNotFoundException在这种情况下不会抛出一个吗?

我还可以做些什么?在您说"使用64位非托管DLL"之前,让我指出没有一个.;)

.net 64-bit pinvoke 32-bit badimageformatexception

448
推荐指数
11
解决办法
46万
查看次数

无法加载文件或程序集...尝试加载格式不正确的程序(System.BadImageFormatException)

我有两个项目,ProjectAProjectB. ProjectB是一个控制台应用程序,依赖于ProjectA.昨天,一切都运转良好,但今天突然我跑了,ProjectB我得到了这个:

BadImageFormatException未处理:
无法加载文件或程序集"ProjectA,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null"或其依赖项之一.尝试加载格式不正确的程序.

两者都只是常规项目,不依赖于任何其他非.Net项目.两者都是.Net - 没有本机代码,也没有P/Invoke.我有其他项目依赖ProjectA并仍然工作得很好.

我尝试过的事情:

  • 确保两个项目都设置为"任何CPU",并选中" 构建"复选框.他们是.
  • 确保两个项目都针对相同的目标框架(.Net 4.0 Client Profile).
  • 在ProjectB - >引用 - > ProjectA - >属性下,确保"复制本地"设置为"True" _ (我验证正在正确复制ProjectA.dll)
  • 清理/重建解决方案.我甚至尝试手动删除两个项目中的/ bin和/ obj文件夹.
  • 重新启动Visual Studio.重启我的电脑.
  • 查看存储库的全新副本.

但我仍然得到同样的错误.我不知道我做了什么导致这个,也不知道如何解决它.有任何想法吗?

c# exception console-application badimageformatexception

376
推荐指数
10
解决办法
43万
查看次数

无法加载文件或程序集异常

有关可能导致此异常的原因的任何想法?

我有一个webservice proj,当我加载我得到的链接

无法加载文件或程序集"Interop.DIB"或其依赖项之一.尝试加载格式不正确的程序.
异常详细信息:System.BadImageFormatException:无法加载文件或程序集"Interop.DIB"或其依赖项之一.尝试加载格式不正确的程序.

内部例外:

[BadImageFormatException:无法加载文件或程序集"Interop.DIB"或其依赖项之一.试图加载格式不正确的程序.]

[ConfigurationErrorsException:无法加载文件或程序集"Interop.DIB"或其依赖项之一.试图加载格式不正确的程序.]

[HttpException(0x80004005):无法加载文件或程序集"Interop.DIB"或其依赖项之一.试图加载格式不正确的程序.]

版本信息:
Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.272

c# web-services

30
推荐指数
4
解决办法
8万
查看次数

"无法加载文件或程序集或其中一个依赖项.尝试加载格式不正确的程序."

在VS中进行调试时,在VS中启动调试时会引发错误.

错误如下:

Could not load file or assembly 'p4dn, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null' 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 'p4dn, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt …
Run Code Online (Sandbox Code Playgroud)

asp.net

15
推荐指数
3
解决办法
3万
查看次数

在C++/CLI项目中识别有问题的依赖项

我的应用程序编译正常,但我得到以下运行时错误:

System.IO.FileNotFoundException was unhandled
  HResult=-2147024770
  Message=Could not load file or assembly {Wrapper} or one of its dependencies. The specified module could not be found.
Run Code Online (Sandbox Code Playgroud)

调用Application中对Wrapper的引用看起来是正确的.Wrapper dll存在于正确的位置.

这个项目用于在别人的系统上构建和运行,我看过几次.该人/计算机不再可用.自上次成功构建和运行以来,某些依赖项的某些路径已发生更改,我已修复了与此相关的所有编译错误.

只是为了澄清我的项目结构:

图形

Digraph G
{
    App [ label = "My C# Application"]
    Wrapper [ label = "C++/CLI Wrapper"]
    Lib [ label = "C++ Library"]
    Dll [ label = "My helper C# DLL"]
    CDep [ label = "Series of deep C++ dependencies managed \n by CMake for Lib, hard coded relative paths for Wrapper."]
    App->Wrapper->Lib->CDep; …
Run Code Online (Sandbox Code Playgroud)

c# dependencies c++-cli cmake visual-studio-2010

10
推荐指数
1
解决办法
3847
查看次数

AspNetCompiler - 尝试使用不正确的格式加载程序

我正在构建一个仅64位的Web应用程序(AssemblyA)并引用我已经构建的另一个应用程序,它也是64位(AssemblyB).

当我添加AssemblyB作为引用时AssemblyA,我在Visual Studio中得到以下编译错误:

ASPNETCOMPILER无法加载文件或程序集"AssemblyB"或其依赖项之一.尝试加载格式不正确的程序.

我的应用程序的平台目标设置都设置为x64,两个Target Framework设置都是.Net Framework 4.6Prefer 32bit is unchecked.

我尝试引用AssemblyBin的每个依赖引用AssemblyA,确保所有依赖引用的版本相同.

我使用过这个问题:如何确定.NET程序集是为x86还是x64构建的?确认所有引用的程序集是MSILAMD64.

我使用了aspnet_compiler.exe命令行工具并errorstack启用了选项,并获得了以下堆栈跟踪:

[BadImageFormatException]:无法加载文件或程序集"AssemblyB"或其依赖项之一.尝试加载格式不正确的程序.

at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName,String codeBase,Evidence assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntro spection,Boolean suppressSecurityChecks)

在System.Reflection.RuntimeAssembly.nLoad(的AssemblyName文件名,字符串的代码库,证据assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark&S tackMark,IntPtr的pPrivHostBinder,布尔throwOnFileNotFound,布尔forIntros pection,布尔suppressSecurityChecks)

在System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(的AssemblyName assemblyRef,证据assemblySecurity,RuntimeAssembly reqAssembly,StackCrawlMark&stackMark,IntPtr的pPrivHostBinder,布尔throwOnFileNotFound,布尔forIntrospection,布尔suppressSecurityChecks)

在System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Evidence assemblySecurity,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,Boolean forIntrospection)

在System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Evidence assemblySecurity,StackCrawlMark&stackMark,Boolean forIntrospection)

在System.Reflection.Assembly.Load(String assemblyString)

在System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName,Boolean starDirective)

[ConfigurationErrorsException]:无法加载文件或程序集"AssemblyB"或其依赖项之一.尝试加载格式不正确的程序.

在System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName,Boolean starDirective)

在System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomain …

.net c# compiler-errors compilation badimageformatexception

5
推荐指数
1
解决办法
647
查看次数

修复:尝试加载格式不正确的程序

在尝试从我的项目添加*.dll"AWSREMOTELIB"时,我遇到了这个问题......

BadImageFormatException的屏幕截图

BadFormatException是什么意思?

c# exception

-5
推荐指数
2
解决办法
2万
查看次数