CorFlags.exe、System.Data.SQLite.dll 和 BadImageFormatException [英] CorFlags.exe, System.Data.SQLite.dll and BadImageFormatException

查看:25
本文介绍了CorFlags.exe、System.Data.SQLite.dll 和 BadImageFormatException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行 CorFlags.exe针对 System.Data.SQLite.dll 来自 http://sqlite.phxsoftware.com/a> 产生以下输出.

Running CorFlags.exe against System.Data.SQLite.dll from http://sqlite.phxsoftware.com/ produces the following output.

Version   : v2.0.50727
CLR Header: 2.5
PE        : PE32
CorFlags  : 24
ILONLY    : 0
32BIT     : 0
Signed    : 1

如您所见,没有指定32BITPE 等于PE32.根据从 32 位移动到 64-.NET Framework 上的位应用程序开发,这意味着程序集是Any CPU.但是,使用 64 位应用程序中的程序集会导致错误:

As you can see, 32BIT is not specified and PE is equal to PE32. According to Moving from 32-bit to 64-bit application development on .NET Framework, this means that the assembly is Any CPU. However, using the assembly from a 64 bit application results in an error:

System.BadImageFormatException: 可以不加载文件或程序集'System.Data.SQLite' 或其中之一依赖关系.已尝试加载一个不正确的程序格式.文档名称:'System.Data.SQLite'

System.BadImageFormatException: Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. An attempt was made to load a program with an incorrect format. File name: 'System.Data.SQLite'

如果CorFlags.exe 报告Any CPU,为什么会出现异常?程序集是否错误地标记为 32BIT: 0?

If CorFlags.exe is reporting Any CPU, why does the exception occur? Is the assembly incorrectly marked with 32BIT: 0?

我知道也有 64 位版本可用,我只是想知道是什么导致了错误.

I know that there is a 64-bit version available too, I'm just want to know what is causing the error.

推荐答案

您正在使用的 System.Data.SQLite.dll 文件是一个 混合模式程序集,这意味着它不是纯 .NET 代码(另请参阅ILONLY : 0"标志),它还包含非托管机器代码,不能是任何 CPU".因此,由于 DLL 包含 32 位本机代码,因此只能将其加载到 32 位进程中,否则会发生 BadImageFormatException.

The System.Data.SQLite.dll file you are using is a mixed-mode assembly, which means it is not a pure .NET code (see also the "ILONLY : 0" flag), it contains also unmanaged machine code, which cannot be "Any CPU". So, as the DLL contains 32-bit native code, it can be loaded only into 32-bit process, otherwise a BadImageFormatException occurs.

这篇关于CorFlags.exe、System.Data.SQLite.dll 和 BadImageFormatException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆