IT评测·应用市场-qidao123.com技术社区

标题: SQLite 由于 mscoree.dll 损坏导致 BadImageFormatException 试图加载格式 [打印本页]

作者: 北冰洋以北    时间: 2024-9-5 09:35
标题: SQLite 由于 mscoree.dll 损坏导致 BadImageFormatException 试图加载格式
本文记载 SQLite.Interop.dll 由于 mscoree.dll 文件损坏而在加载时抛出 BadImageFormatException 错误,错误信息是 0x8007000B 试图加载格式不正确的程序
对应的英文错误信息如下
  1. An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
复制代码
常见的错误堆栈如下
  1. System.BadImageFormatException: 试图加载格式不正确的程序。 (0x8007000B)
  2.    in SQLiteErrorCode UnsafeNativeMethods.sqlite3_open_interop(byte[] utf8Filename, byte[] vfsName, SQLiteOpenFlagsEnum flags, int extFuncs, ref IntPtr db)
  3.    in void SQLite3.Open(string strFilename, string vfsName, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, int maxPoolSize, bool usePool)
  4.    in void SQLiteConnection.Open()
  5.    in void AsyncDbConnection.Open()
  6.    in IAsyncDbConnection DataConnection.EnsureConnection(bool connect)
  7.    in DbConnection DataConnection.get_Connection()
  8.    in int DataConnection.LinqToDB.Common.Internal.IConfigurationID.get_ConfigurationID()
  9.    in new Query(IDataContext dataContext, Expression expression)
  10.    in new Query<T>(IDataContext dataContext, Expression expression)
  11.    in Query<T> Query<T>.CreateQuery(ExpressionTreeOptimizationContext optimizationContext, ParametersContext parametersContext, IDataContext dataContext, Expression expr)
  12.    in Query<T> Query<T>.GetQuery(IDataContext dataContext, ref Expression expr, out bool dependsOnParameters)
  13.    in Query<T> ExpressionQuery<T>.GetQuery(ref Expression expression, bool cache, out bool dependsOnParameters)
  14.    in TResult ExpressionQuery<T>.System.Linq.IQueryProvider.Execute<TResult>(Expression expression)
  15.    in TSource Queryable.FirstOrDefault<TSource>(IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
  16.    in LocalCoursewareEntry CoursewareSqliteDbReader.GetCoursewareEntry(string localId)+(ITable<LocalCoursewareEntry> tb) => { }
  17.    in TReturn CoursewareSqliteDbOperator.ExecuteOnCoursewareTable<TReturn>(Func<ITable<LocalCoursewareEntry>, TReturn> query)+(DataConnection conn) => { }
  18.    in TReturn SqliteDbOperator.ExecuteQuery<TReturn>(Func<DataConnection, TReturn> func)
复制代码
  1. System.BadImageFormatException: 试图加载格式不正确的程序。 (0x8007000B)
  2.   ?, in SQLiteErrorCode UnsafeNativeMethods.sqlite3_config_none(SQLiteConfigOpsEnum op)
  3.   ?, in bool SQLite3.StaticIsInitialized()
复制代码
错误原因是 mscoree.dll 文件损坏,这个 mscoree.dll 不是放在应用程序文件夹下的,所在的系统路径如下
如果当前能抓到复现的系统环境,可以尝试用自己开辟机正常的 mscoree.dll 更换出现问题的呆板的文件,预期更换之后能正常工作。如更换之后不能正常工作,大概是错误将 x86 和 x64 文件给混了,大概是 SQLite.Interop.dll 文件本身或其他依赖出错
此问题如利用 Dependencies 工具,将 SQLite.Interop.dll 文件拖入,则可以看到 mscoree.dll 被打了感叹号
我尝试将一个用户装备上的 mscoree.dll 拖回来分析,利用 dumpbin 工具分析提示无效的格式文件
  1. C:\Program Files\Microsoft Visual Studio\2022\Professional>dumpbin C:\lindexi\Work\mscoree.dll
  2. Microsoft (R) COFF/PE Dumper Version 14.40.33811.0
  3. Copyright (C) Microsoft Corporation.  All rights reserved.
  4. Dump of file C:\lindexi\Work\mscoree.dll
  5. C:\lindexi\Work\mscoree.dll : warning LNK4048: 无效的格式文件;已忽略
  6.   Summary
复制代码
尝试利用二进制查看工具打开 mscoree.dll 文件
读取到的内容完全不是 PE 文件格式,证明文件完全被损坏
我没有继续了解为什么 mscoree.dll 文件出错了

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 IT评测·应用市场-qidao123.com技术社区 (https://dis.qidao123.com/) Powered by Discuz! X3.4