Reputation: 450
I developed some C# assembly with UDF for SQL Server 2008. In particular I have some functions which use SQLite database. I added there trace listener to write a log file to see what is happing inside. But there is a problem - on every call to UDF function it is flooding log file with messages like these:
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)
I can see that on every call it is logging ~18 of such messages for every of following parameters:
"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"
It is a bit annoying to see all the messages in log, difficult to track log messages which related to functionality which I'm interested in.
Could you please advice - how could I get rid of that extra/unwanted trace messages?
Maybe I need to do some special SQLlite API call to disable loading of all that settings?
Note: to make my UDF assembly working under from SQL Server CLR engine I copied SQLite.Interop.dll, System.Data.SQLite.dll and System.Data.SQLite.dll.config files into C:\Windows\system32. As you can see System.Data.SQLite.dll.config file is in the same dir as System.Data.SQLite.dll but it does not help.
Note: both DLLs SQLite.Interop.dll, System.Data.SQLite.dll has version 1.0.99.0.
Thank you in advance.
Upvotes: 2
Views: 1279
Reputation: 23757
I had the same issue, though I was using Fody/Costura to embed the System.Data.SQLite libraries in my assembly (it's unclear if you're doing something similar).
The error you show comes from 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;
}
The method GetAssemblyDirectory
returns null
if it cannot figure out the path of the assembly, which will make Path.Combine
throw. In my case, because Costura loads its assemblies from a stream, they have no directory so GetAssemblyDirectory
fails.
The good news is that I opened a ticket with System.Data.SQLite and it was fixed almost immediately. Hopefully it will be pushed out soon.
Upvotes: 2