SQLite - 如何摆脱烦人的跟踪消息 - “本机库预加载器无法获得设置..值”

本文关键字:加载 设置 本机 何摆脱 跟踪 SQLite 消息 | 更新日期: 2023-09-27 18:36:29

我用UDF为SQL Server 2008开发了一些C#程序集。特别是我有一些使用SQLite数据库的函数。我在那里添加了跟踪侦听器来编写日志文件以查看里面有什么。但是有一个问题 - 每次调用UDF函数时,它都会用如下消息淹没日志文件:

20160226,191636.67 [P5816]/[T4]  Native library pre-loader failed to get setting "No_PreLoadSQLite" value: System.ArgumentNullException: Value cannot be null.
Parameter name: path1
   at System.IO.Path.Combine(String path1, String path2)
   at System.Data.SQLite.UnsafeNativeMethods.GetXmlConfigFileName()
   at System.Data.SQLite.UnsafeNativeMethods.GetSettingValue(String name, String default)

我可以看到,在每次调用中,它都会为以下每个参数记录~18条此类消息:

"No_PreLoadSQLite", "PreLoadSQLite_NoSearchForDirectory",  "PreLoadSQLite_ProcessorArchitecture",
"PreLoadSQLite_ProcessorArchitecture", "PreLoadSQLite_BaseDirectory",   "PreLoadSQLite_UseAssemblyDirectory",
"PreLoadSQLite_ProcessorArchitecture", "No_PreLoadSQLite", "PreLoadSQLite_NoSearchForDirectory",
"PreLoadSQLite_ProcessorArchitecture", "PreLoadSQLite_ProcessorArchitecture", "PreLoadSQLite_BaseDirectory",
"PreLoadSQLite_UseAssemblyDirectory", "PreLoadSQLite_ProcessorArchitecture", "No_SQLiteConnectionNewParser",
"DefaultFlags_SQLiteConnection", "No_SQLiteFunctions", "SQLite_ForceLogPrepare"

在日志中看到所有消息有点烦人,很难跟踪与我感兴趣的功能相关的日志消息。

您能否提供建议 - 我如何摆脱额外/不需要的跟踪消息?

也许我需要做一些特殊的SQLlite API调用来禁用所有这些设置的加载?

注意:为了使我的UDF程序集在SQL Server CLR引擎下工作,我将SQLite.Interop.dll,System.Data.SQLite.dll和System.Data.SQLite.dll.config文件复制到C:''Windows''system32中。如您所见,System.Data.SQLite.dll.config 文件与 System.Data.SQLite 位于同一目录中.dll但它没有帮助。

注意:两个 DLL SQLite.Interop.dllSystem.Data.SQLite.dll 的版本均为 1.0.99.0。

提前谢谢你。

SQLite - 如何摆脱烦人的跟踪消息 - “本机库预加载器无法获得设置..值”

我遇到了同样的问题,尽管我正在使用Fody/Costura在我的程序集中嵌入System.Data.SQLite库(目前还不清楚您是否在做类似的事情)。

您显示的错误来自以下代码:

private static string GetXmlConfigFileName()
{
    string directory;
    string fileName;
#if !PLATFORM_COMPACTFRAMEWORK
    directory = AppDomain.CurrentDomain.BaseDirectory;
    fileName = Path.Combine(directory, XmlConfigFileName);
    if (File.Exists(fileName))
        return fileName;
#endif
    directory = GetAssemblyDirectory();
    fileName = Path.Combine(directory, XmlConfigFileName);
    if (File.Exists(fileName))
        return fileName;
    return null;
}

该方法GetAssemblyDirectory如果无法找出程序集的路径,则返回null,这将使Path.Combine抛出。 就我而言,由于 Costura 从流加载其程序集,因此它们没有目录GetAssemblyDirectory因此会失败。

好消息是,我用System.Data.SQLite开了一张票,它几乎立即就被修复了。 希望它能很快被推出。