升级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
可以找到日志here。
我希望在座的任何人都可以帮助我。
所有平台都设置为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的最新版本现在是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
的方法。
答案 0 :(得分:1)
我遇到了这个问题而且分辨率很简单:我在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发布了我的解决方案,有些人说这也适用于他们。