未设置为对象实例的对象引用



升级Microsoft.NETCore.UniversalWindowsPlatform后,我无法在发布中编译我的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 FilesWindowsApps<project>_1.8.0.0_x64__r1myykanma94rclrjit.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 FilesWindowsApps<app-name>_1.8.0.0_x64__r1myykanma94rWindows.winmd has a non-empty exported type reference table. Every Windows Runtime assembly must have an empty exported type reference table.

UPDATE 3
我发现卸载Win2D.uwp并自己编译XLabs是可行的方法。

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

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

请记住,在更新时,我替换了对Newtonsoft库的所有引用,即。在我的pcl中,我现在引用便携式版本libportable-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>.nugetpackagesnewtonsoft.json9.0.1libportable-net45+wp80+win8+wpa81的引用

很久以前在Xamarin论坛上发布了我的解决方案,有些人说这对他们也有效。

最新更新