【问题标题】:TypeLoadException when I try to get a SQLite connection from Windows Phone 8当我尝试从 Windows Phone 8 获取 SQLite 连接时出现 TypeLoadException
【发布时间】:2014-11-27 05:24:28
【问题描述】:

我目前正在使用 Xamarin.Forms 开发 Windows Phone 应用程序。 为此,我需要使用 SQLite 数据库才能拥有 Android 和 iOS 的跨平台应用程序。

所以我按照以下文档中描述的步骤操作:Working with a local database using SQLite.Net with Xamarin.Forms

问题是当我尝试使用以下代码在 Windows Phone 8 上建立 SQLite 连接时出现错误:

var plat = new SQLite.Net.Platform.WindowsPhone8.SQLitePlatformWP8();

调用此方法会引发 TypeLoadException 并带有以下消息:

[System.TypeLoadException] = {System.TypeLoadException: Method 'ExtendedErrCode' in type 
'SQLite.Net.Platform.WindowsPhone8.SQLiteApiWP8' from assembly
'SQLite.Net.Platform.WindowsPhone8, Version=2.3.0.0, Culture=neutral, PublicKeyToken=null'
does not have an implementation.
at SQL...

我不知道为什么会出现这样的错误。如果您有任何想法,那就太好了!

提前感谢任何可以帮助我的人

【问题讨论】:

  • 我不明白的是,在我的 NuGet 包管理器中,据说安装的 SQLite.Net PCL - WindowsPhone8 平台版本是 2.4.0 版本,而错误消息显示“版本” =2.3.0.0'。会不会和我遇到的问题有关?
  • 一定要检查版本(检查引用指向的位置)。
  • 存在不一致:我的参考来自 2.3.0.0 版本,而我从我的 NuGet 包管理器添加了 2.4.0 版本。但我只为 SQLite.Net.Platform.WindowsPhone8 发现了这个问题。 SQLite.Net 参考在版本 2.4.0.0 上。我该如何解决这个问题?
  • 正如我所说,检查引用的位置(项目/引用)并检查 NuGet 创建的包文件夹内的内容。
  • 当我转到 SQLite.Net.Platform.WindowsPhone8 包的属性时,我发现: * 版本 2.3.0.0 * ...\packages\SQLite.Net.Platform.WindowsPhone8.2.4 .0\lib\windowsphone8\x86\SQLite.Net.Platform.WindowsPhone8.dll 所以文件夹显示版本 2.4.0 但不是属性中指定的版本

标签: sqlite windows-phone-8 xamarin.forms typeloadexception sqlite.net


【解决方案1】:

如果您在 SQLite.Net.Platform.WindowsPhone8 的参考属性路径中看到有一个指向 x86 平台系统的链接。删除引用并在安装 ARM 平台的 nuget 包中搜索,一切正常。

【讨论】:

    【解决方案2】:

    我在 AssemblyInfo.cs 中添加 [assembly: Dependency (typeof (SQLite_WinPhone))] 解决了这个错误 但现在我又遇到了一个错误。

    【讨论】:

      猜你喜欢
      • 2015-08-27
      • 2012-11-28
      • 2020-04-15
      • 1970-01-01
      • 1970-01-01
      • 2020-01-20
      • 1970-01-01
      • 2021-05-28
      • 1970-01-01
      相关资源
      最近更新 更多