Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NLog and SQLite Error

Tags:

c#

sqlite

nlog

I am trying to get NLog to properly log to a SQLite database.
I am able to interact with the SQLite database aside from NLog.

When I force Internal Logging of NLog, I see the following error:

Error initializing target Database Target[db] System.TypeLoadException: Could not load type 'System.Data.SQLite' from assembly 'NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c'.

My NLog configuration has the following parameters:

  • dbProvider="System.Data.SQLite" keepConnection="false"
  • connectionString="Data Source=${basedir}\Database.s3db;"
  • commandText="INSERT into Log(Timestamp, Loglevel, Logger, Callsite, Message) values(@Timestamp, @Loglevel, @Logger, @Callsite, @Message)"

What am I missing?

like image 612
Todd Zetlan Avatar asked Mar 09 '26 03:03

Todd Zetlan


1 Answers

Its a very old question but my answer might help if anyone else faces the same issue:

In my case the version number in NLog.config file was the issue which was not the one what I have added System.Data.SQLite.dll. To do so:

  • Right click on System.Data.SQLite.dll and then click Properties
  • Click Details for actual version number
  • Write correct version in NLog.config file

enter image description here

enter image description here

like image 55
S.ATTA.M Avatar answered Mar 10 '26 16:03

S.ATTA.M



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!