We want to use AppFabric cache on our projects with using Sqlite including ReadThruogh-WriteBehind feature. I successfully created Provider and registered to GAC. If i chose mssql service as data provider, everything works successfully. On the other hand, if i chose sqlite, it throws an exception at this line on Provider in GAC .
SQLiteConnection conn = new SQLiteConnection(@"path");
This exception comes from Provider in GAC, but if i write this line in service, it works. So problem is, if i want to connect sqlite from GAC, it throws an exception:
The cache provider threw an exception during read.
There is no more explanation in error message, but if try to connect sqlite from service, it connects successfully. Sqlite db file allows everyone to read.
It seems there is an authentication problem or something like that. What can be the solution?
After debugging provider in GAC, issue was about System.Data.SQLite.dll. I had to register that dll into a GAC too, because it tries to find that dll from gac too, for this reason it threw an exception. You need to be sure that, dll should have strong name. To make it has strong name, you need to do following instructions,
1. sn -k keyPair.snk
2. ildasm System.Data.SQLite.dll
3. /out:System.Data.SQLite.il ren System.Data.SQLite.dll
4. System.Data.SQLite.dll.orig ilasm System.Data.SQLite.il /dll /key=
keyPair.snk
If your dll has already strong name(you can check it from dll properties) you dont need to do these steps. you can directly register dll into a GAC by following this code,
gacutil -i System.Data.SQLite.dll
I hope it will be useful.