重现步骤:
- 打开带有最新更新的 Visual Studio 2017。
- 在 10240 中创建一个 UWP 项目(这不是强制性的,它在所有版本中都已损坏)
System.Memory
从 nuget 包安装(单击包含预发行版)将此代码复制粘贴到 MainPage.cs
private void MainPage_Loaded(object sender, RoutedEventArgs e) { void Recursive(ReadOnlySpan<char> param) { if (param.Length == 0) return; tx1.Text += Environment.NewLine; tx1.Text += new string(param.ToArray()); Recursive(param.Slice(1)); } ReadOnlySpan<char> mySpan = "Why things are always broken in Visual Studio".AsSpan(); Recursive(mySpan); }
将此复制粘贴到 MainPage.xaml
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <TextBlock x:Name="tx1" HorizontalAlignment="Left" FontSize="48" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top"/> </Grid>
从 Debug 切换到 Release x64 并确保“使用 .Net Native 工具链编译”。
单击播放。
收到此错误:
------ 构建开始:项目:App12,配置:Release x64 ------
App12 c:\Users\myuser\documents\visual studio 2017\Projects\App12\App12\bin\x64\Release\App12 .exe
处理应用程序代码
C:\Users\myuser.nuget\packages\microsoft.net.native.compiler\1.7.3\tools\Microsoft.NetNative.targets(697,5): error : Internal compiler error: Object reference not设置为对象的实例。
========== 构建:0 成功,1 失败,0 最新,0 跳过 ==========
========= 部署:0成功,0失败,0跳过==========
我做错了什么?这适用于没有 .NET Native 的调试和发布。谢谢。