【问题标题】:SQLite - how to get rid of annoying trace messages - "Native library pre-loader failed to get setting ... value"?SQLite - 如何摆脱烦人的跟踪消息 - “Native library pre-loader failed to get setting ... value”?
【发布时间】:2016-06-10 02:36:20
【问题描述】:

我使用 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.dllSystem.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。

提前谢谢你。

【问题讨论】:

    标签: c# sqlite sql-server-2008


    【解决方案1】:

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

    您显示的错误来自this code

    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 失败。

    好消息是我opened a ticket with System.Data.SQLite 几乎立即修复。希望它很快就会推出。

    【讨论】:

      猜你喜欢
      • 2011-04-19
      • 1970-01-01
      • 2015-03-12
      • 2011-02-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-16
      • 2011-07-04
      相关资源
      最近更新 更多