xamarin - UWP-对象引用未设置为对象的实例

标签 xamarin compiler-errors uwp xlabs

升级Microsoft.NETCore.UniversalWindowsPlatform后,由于得到了Internal compiler error: Object reference not set to an instance of an object,我无法再在Release中编译我的Xamarin应用程序项目。

我正在使用这些NuGet软件包

Acr.UserDialogs   5.2.2
ExifLib.PCL   1.0.1   (in portable project)
Microsoft.NETCore.UniversalWindowsPlatform   5.2.0
MR.Gestures   1.3.4
Newtonsoft.Json   7.0.1   (in portable project)
Splat   1.6.2   (in portable project)
SQLite.Net.Core-PCL   3.1.1
SQLite.Net-PCL   3.1.1
Win2D.uwp   1.18.0   (in portable project)
Xam.Plugins.Settings   2.1.0
Xamarin.Forms   2.3.0.107
Xamarin.Insights   1.12.3
XLabs.Core   2.2.0-pre02
XLabs.Forms   2.2.0-pre02
XLabs.IoC   2.2.0-pre02
XLabs.Platform   2.2.0-pre02
XLabs.Serialization   2.2.0-pre02

可以找到一个日志here

我希望这里的任何人都能帮助我。

所有平台都设置为Compile with .NET Native tool chain

更新
如果我自己构建XLabs并将Compile with .NET Native tool chain设置为未选中。发生这些错误。

应用 list
发现错误:应用 list 测试检测到以下错误:<project> takes a dependency on Microsoft .Net Native Runtime Package 1.x framework but is missing the framework dependency declaration in the manifest.
二进制分析器
发现错误:二进制分析器测试检测到以下错误:File C:\Program Files\WindowsApps\<project>_1.8.0.0_x64__r1myykanma94r\clrjit.dll has failed the AppContainerCheck check.
支持的API
发现错误:支持的API测试检测到以下错误:
API SystemFunction036 in advapi32.dll is not supported for this application type. clrjit.dll calls this API.
API DebugBreak in kernel32.dll is not supported for this application type. clrjit.dll calls this API.
API HeapValidate in kernel32.dll is not supported for this application type. clrjit.dll calls this API.
API LoadLibraryExW in kernel32.dll is not supported for this application type. clrjit.dll calls this API.
API RtlCaptureContext in kernel32.dll is not supported for this application type. clrjit.dll calls this API.
API RtlVirtualUnwind in kernel32.dll is not supported for this application type. clrjit.dll calls this API.
API TlsAlloc in kernel32.dll is not supported for this application type. clrjit.dll calls this API.
API TlsFree in kernel32.dll is not supported for this application type. clrjit.dll calls this API.
API TlsGetValue in kernel32.dll is not supported for this application type. clrjit.dll calls this API.
API TlsSetValue in kernel32.dll is not supported for this application type. clrjit.dll calls this API.
API UnhandledExceptionFilter in kernel32.dll is not supported for this application type. clrjit.dll calls this API.
API VirtualAlloc in kernel32.dll is not supported for this application type. clrjit.dll calls this API.
API VirtualProtect in kernel32.dll is not supported for this application type. clrjit.dll calls this API.
API ExecuteAssembly in uwphost.dll is not supported for this application type. <project>.exe calls this API.
API DllGetActivationFactory in uwphost.dll is not supported for this application type. <project>.UWP.exe has an export that forwards to this API.

更新2

我可以轻松地重写代码,因此不再使用Win2D.uwp。我以某种方式在上周五安装了Microsoft.NETCore.UniversalWindowsPlatform v 5.2.0,但是NuGet中的最新版本现在是v 5.1.0
所以现在我来谈谈这些NuGet软件包
Acr.UserDialogs   5.3.0
ExifLib.PCL   1.0.1   (in portable project)
Microsoft.NETCore.UniversalWindowsPlatform   5.1.0
MR.Gestures   1.3.4
Newtonsoft.Json   7.0.1   (in portable project)
Splat   1.6.2   (in portable project)
SQLite.Net.Core-PCL   3.1.1
SQLite.Net-PCL   3.1.1
Xam.Plugins.Settings   2.1.0
Xamarin.Forms   2.3.0.107
Xamarin.Insights   1.12.3
XLabs.Core   2.2.0-pre02
XLabs.Forms   2.2.0-pre02
XLabs.IoC   2.2.0-pre02
XLabs.Platform   2.2.0-pre02
XLabs.Serialization   2.2.0-pre02

并且此错误发生The assembly Windows in file C:\Program Files\WindowsApps\<app-name>_1.8.0.0_x64__r1myykanma94r\Windows.winmd has a non-empty exported type reference table. Every Windows Runtime assembly must have an empty exported type reference table.
更新3
我发现自己可以自己卸载Win2D.uwp和编译XLabs

最佳答案

我遇到了这个问题,解决方法很简单:我在PCL和UWP项目中都引用了PCL版本 Newtonsoft.Json.dll 。较旧的便携式版本( Portable40 )。

在我更新到最新版本的Newtonsoft.Json.dll (NuGet version 9.0.1)之后,编译异常消失了。

请记住,在更新时,我替换了所有对Newtonsoft libreary的引用,即
现在,在我的PCL中,我引用了便携式版本lib\portable-net40+sl5+wp80+win8+wpa81
现在,在我的启动项目中,我引用了Newtonsoft包(我的project.json文件内容):

{
  "dependencies": {
  "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2",
  "Newtonsoft.Json": "9.0.1",
  "Xamarin.Forms": "2.3.2.127"
  },
  "frameworks": {
    "uap10.0": {}
  },
  "runtimes": {
    "win10-arm": {},
    "win10-arm-aot": {},
    "win10-x86": {},
    "win10-x86-aot": {},
    "win10-x64": {},
    "win10-x64-aot": {}
  }
}

有效地使用对C:\Users\<username>\.nuget\packages\newtonsoft.json\9.0.1\lib\portable-net45+wp80+win8+wpa81的引用。

不久前,我在Xamarin forums上发布了我的解决方案,有人说这对他们也有效。

关于xamarin - UWP-对象引用未设置为对象的实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38097466/

相关文章:

tfs - 使用托管的 tfs 构建服务器构建 Xamarin.Android 时,缺少 Android NDK 工具链目录 '\toolchains'

xamarin - 滚动到带有标题的 Xamarin Forms ListView 的开头

c - 编译包含<math.h>的c代码时需要使用额外的选项

xamarin - 颜色转换器绑定(bind)未被调用

c - 为什么我们不能在 switch 构造中的 case 中使用变量?

c - 如何正确找到 off_t 大小

c# - 如何从 xamarin 表单中的开关中删除开/关文本

c# - 获取 Window.Current.Content 的参数

c# - 双击时使矩形不透明度为零的可重用代码

c# - Xamarin 中的 ListView 错误