Web service: Unable to load DLL 'sqlite3': The specified module could not be found.

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for SQLite
Post Reply
DanielTulp
Posts: 5
Joined: Fri 25 Aug 2017 08:06

Web service: Unable to load DLL 'sqlite3': The specified module could not be found.

Post by DanielTulp » Fri 17 Nov 2017 15:21

I have created a webservice in C# using visual studio 2015 and the Devart ado.net connector for SQLite.
Locally everything is fine, but when I deploy to the server I get this error message:

Code: Select all

EXCEPTION OCCURRED:System.Data.Entity.Core.EntityException: The underlying provider failed on Open. ---> Devart.Data.SQLite.SQLiteException: Unable to open database file ---> System.DllNotFoundException: Unable to load DLL 'sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at Devart.Data.SQLite.bx.sqlite3_open_v2(Byte[] A_0, IntPtr& A_1, Int32 A_2, String A_3)
   at Devart.Data.SQLite.a8.a(String A_0, EncryptionMode A_1, String A_2, Boolean A_3)
   at Devart.Data.SQLite.r.n()
   --- End of inner exception stack trace ---
   at Devart.Data.SQLite.r.n()
   at Devart.Data.SQLite.d.a(o A_0, Object A_1, DbConnectionBase A_2)
   at Devart.Common.DbConnectionFactory.a(DbConnectionPool A_0, o A_1, DbConnectionBase A_2)
   at Devart.Common.DbConnectionPool.a(DbConnectionBase A_0)
   at Devart.Common.DbConnectionPool.GetObject(DbConnectionBase owningConnection)
   at Devart.Common.DbConnectionFactory.b(DbConnectionBase A_0)
   at Devart.Common.DbConnectionClosed.Open(DbConnectionBase outerConnection)
   at Devart.Common.DbConnectionBase.Open()
   at Devart.Data.SQLite.SQLiteConnection.Open()
   at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.<Open>b__36(DbConnection t, DbConnectionInterceptionContext c)
   at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
   at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext)
   at System.Data.Entity.Core.EntityClient.EntityConnection.<Open>b__2()
   at System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute(Action operation)
   at System.Data.Entity.Core.EntityClient.EntityConnection.Open()
I have two folders in my bin folder, x64 and x86, with the sqlite3.dll in it.
I also have Devart.Data.dll, Devart.Data.SQLite.Entity.EF6.dll (I'm using EF 6.2.0), Devart.Data.SQLite.dll and Devart.Data.SQLite.Web.dll in the bin folders.
The databases are in de App_Data/Databases folder and the web.config is as follows:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  </configSections>
  <appSettings>
    <!--V1-->
    <add key="ProductkaartenDevartEntitiesVersionConnectionstring" value="metadata=res://*/ProductkaartenDevart.csdl|res://*/ProductkaartenDevart.ssdl|res://*/ProductkaartenDevart.msl;provider=Devart.Data.SQLite;provider connection string="data source=C:\Projects\WE Projecten\Rekenkernen\WE.Rekenkernen\Data\Productkaarten{0}.sqlite"" />
    <!--V2-->
    <add key="ProductkaartenDevartV2EntitiesVersionConnectionstring" value="metadata=res://*/ProductkaartenDevartV2.csdl|res://*/ProductkaartenDevartV2.ssdl|res://*/ProductkaartenDevartV2.msl;provider=Devart.Data.SQLite;provider connection string="data source=C:\Projects\WE Projecten\Rekenkernen\WE.Rekenkernen\Data\Productkaarten{0}.sqlite"" />
    <add key="ProductResultaatXmlCachePath" value="C:\Projects\WE Projecten\Rekenkernen\WE.Rekenkernen\Data" />
    <add key="ProductIdsToIgnore" value="0" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
    <globalization culture="en-US" uiCulture="en-US" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>
  <entityFramework>
    <providers>
      <provider invariantName="Devart.Data.SQLite" type="Devart.Data.SQLite.Entity.SQLiteEntityProviderServices, Devart.Data.SQLite.Entity.EF6, Version=5.10.1013.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
    </providers>
  </entityFramework>
  <system.data>
    <DbProviderFactories>
      <remove invariant="Devart.Data.SQLite" />
      <add name="dotConnect for SQLite" invariant="Devart.Data.SQLite" description="Devart dotConnect for SQLite" type="Devart.Data.SQLite.SQLiteProviderFactory, Devart.Data.SQLite, Version=5.10.1013.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
    </DbProviderFactories>
  </system.data>
</configuration>
I'm using the pro version of the connector, we have a license.
What am I doing wrong?

DanielTulp
Posts: 5
Joined: Fri 25 Aug 2017 08:06

Re: Web service: Unable to load DLL 'sqlite3': The specified module could not be found.

Post by DanielTulp » Mon 20 Nov 2017 15:30

I fixed it by moving the webservice to our VPS and installing the dotnet connector with the minimum installation option

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Web service: Unable to load DLL 'sqlite3': The specified module could not be found.

Post by Shalex » Tue 21 Nov 2017 14:18

DanielTulp wrote:

Code: Select all

[...] Devart.Data.SQLite.SQLiteException: Unable to open database file ---> System.DllNotFoundException: Unable to load DLL 'sqlite3': The specified module could not be found. [...]
I have two folders in my bin folder, x64 and x86, with the sqlite3.dll in it.
This should work.

1. Make sure that sqlite3.dll libraries in the x64 and x86 folders are of a correct bitness:
x86 -> copy it from C:\Program Files (x86)\Devart\dotConnect\SQLite\sqlite3.dll
x64 -> copy it from C:\Program Files (x86)\Devart\dotConnect\SQLite\x64\sqlite3.dll

2. JIC: our code looks for sqlite3.dll via the AppDomain.CurrentDomain.BaseDirectory functionality.

Post Reply