0

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

我正在使用这些 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

可以在此处找到日志。

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

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

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

发现应用清单
错误:应用清单测试检测到以下错误: <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 中的最新版本是 now 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自己是要走的路。

4

1 回答 1

1

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

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

请记住,更新时我替换了对 Newtonsoft 库的所有引用,即在我的 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 论坛上发布了我的解决方案,有些人说这也适用于他们。

于 2017-05-22T16:19:51.690 回答