2017-05-05 386 views
1

我有一個Xamarin Forms解決方案。我添加了sqlite-net-pcl作爲所有項目的參考。它在Android上運行良好,但在Windows 8.1和Windows Phone 8.1上崩潰。我有一個IOS項目,但目前我沒有OSX來試用它。無法加載DLL'e_sqlite3':無法找到指定的模塊

我用這個在Windows項目中訪問數據庫:

using System.IO; 
using SQLite; 
using Xamarin.Forms; 
using HelloXamarin.Windows; 
using Windows.Storage; 

[assembly: Dependency(typeof(SQLiteDb))] 

namespace HelloXamarin.Windows 
{ 
    public class SQLiteDb : ISQLiteDb 
    { 
     public SQLiteAsyncConnection GetConnection(string databaseName) 
     { 
      var documentsPath = ApplicationData.Current.LocalFolder.Path; 
      var path = Path.Combine(documentsPath, databaseName); 
      return new SQLiteAsyncConnection(path); 
     } 
    } 
} 

這裏是我的引用:

References

試圖訪問時,我得到這個異常數據庫:

「SQLite.SQLiteConnection」的類型初始值設定項引發異常。

無法加載DLL'e_sqlite3':無法找到指定的模塊。 (從HRESULT異常:0x8007007E)

  • 在SQLitePCL.SQLite3Provider_e_sqlite3.NativeMethods.sqlite3_win32_set_directory(UInt32的directoryType,字符串目錄路徑)
  • 在SQLitePCL.SQLite3Provider_e_sqlite3..ctor()
  • 在SQLitePCL.Batteries_V2.Init( )在SQLite.SQLiteConnection..cctor()

我不知道如何解決這個問題,請幫助我!

整體解決方案可在GitHub上: https://github.com/apspot/HelloXamarin

回答

0

您需要添加SQLite的擴展。

  1. 轉到工具>擴展和更新
  2. 到網上,然後搜索的SQLite。
  3. 下載SQLite,讓Windows運行時

enter image description here

  • 在您的Windows項目,添加引用,並確保您添加擴展。
  • enter image description here

    而且從引用刪除Microsoft.VCLibs。

    +0

    我說SQLite,讓Windows運行時,但問題依然存在:[鏈接](https://ibb.co/iUwYo5) –

    +0

    您是否也引用了Visual Studio Runtime C++ 2013庫? –

    +0

    如果您的意思是「Microsoft Visual C++ 2013運行時軟件包...」比添加它作爲參考,您可以在[此屏幕截圖](https://ibb.co/iUwYo5) –

    0

    嘗試引用通用Windows平臺應用程序的Visual C++ 2015 Runtime。這爲我整理出來。

    1. 轉到參考
    2. 添加引用
    3. 擴展。
    4. 檢查 「的Visual C++ 2015年運行通用的Windows平臺應用程序」
    5. OK
    +0

    上看到它。謝謝您的回答。不幸的是,我現在無法檢查它,因爲我有Visual Studio許可問題:( –

    相關問題