2017-05-05 116 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许可问题:( –

    相关问题