CorFlags.exe, System.Data.SQLite.dll and BadImageFormatException

荒凉一梦 提交于 2019-12-30 10:00:54

问题


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

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: 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'

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

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


回答1:


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.




回答2:


If you download the SQLite-1.0.66.0-binaries.zip file from sourceforget.net then this contains a bin/x64 directory with a System.Data.SQLite.dll file which is what you are looking for.

It also has an Itanium directory too..

The URL is:

http://sourceforge.net/projects/sqlite-dotnet2/files/SQLite%20for%20ADO.NET%202.0/1.0.66.0/



来源:https://stackoverflow.com/questions/4816529/corflags-exe-system-data-sqlite-dll-and-badimageformatexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!