【问题标题】:Exception: Unable to create an instance of "TextBox" in Windows 10 Build 16232例外:无法在 Windows 10 Build 16232 中创建“TextBox”实例
【发布时间】:2017-12-30 20:00:48
【问题描述】:

我刚刚完成了 Windows 10 Build 16232 的全新安装,并使用 UWP、.NET 和 Xamarin“默认”包安装了 Visual Studio Community 2017 Preview。我创建了一个空白的 UWP 应用,放置了一个 TextBox,然后……出错了。

这是 XAML:

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <TextBox Text="Hello World!"/>
</Grid>

现在,对于错误:

Exception: Unable to create an instance of "TextBox". 

at Microsoft.VisualStudio.DesignTools.Designer.InstanceBuilders.InstanceBuilderOperations.InstantiateType(Type type, Boolean supportInternal)
at Microsoft.VisualStudio.DesignTools.Designer.InstanceBuilders.ClrObjectInstanceBuilder.InstantiateTargetType(ILocalInstanceBuilderContext context, ViewNode viewNode)
at Microsoft.VisualStudio.DesignTools.Designer.InstanceBuilders.ClrObjectInstanceBuilder.Instantiate(ILocalInstanceBuilderContext context, ViewNode viewNode)
at Microsoft.VisualStudio.DesignTools.UwpDesigner.InstanceBuilders.FrameworkElementInstanceBuilder.Instantiate(ILocalInstanceBuilderContext context, ViewNode viewNode)
at Microsoft.VisualStudio.DesignTools.Designer.InstanceBuilders.LocalInstanceManager.CreateInstance(IInstanceBuilder builder, ViewNode viewNode)

TargetInvocationException : Exception has been thrown by the target of an invocation.

at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)

AccessViolationException : Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

at Windows.UI.Xaml.Controls.TextBox..ctor()

这是我尝试过的:

  • 调试 x86
  • 调试 ARM
  • 调试 x64
  • 以管理员身份运行
  • chkdsk
  • 重新安装 Visual Studio
  • 重新安装 Windows 10 Build 16232 (慢响)
  • 安装 Visual Studio Community 2017
  • 卸载 Xamarin
  • 升级到 Windows 10 Build 16241 (Fast Ring)

所有其他通用控件确实工作,但不是那个。我如何使它工作?问题只出在设计师身上;我可以很好地编译应用程序。

【问题讨论】:

  • 你现在似乎处于奇怪的境地。但是为什么是 Preview 版本的 VS 2017 和 Insider 版本的 Windows 10。你知道两者都处于测试状态,对吧?至少安装稳定版VS 2017
  • @Nobody 是的,这就是我现在正在尝试做的事情,但是,Community 2017 的安装崩溃了。我必须卸载所有内容并仅重新安装 Community 2017,每次修改都需要几个小时。对于您的问题,我确实使用了所有可用的测试版软件,因为在它们发布之前我会很开心地测试它们(当然也会遇到各种错误)。
  • 然后玩得开心处理这个错误:) 因为我没有看到使用 beta 软件编码的意义。无论如何,这是你的方式。但我相信这个问题可以通过使用 stable 构建来解决。希望 SO 的其他人会放弃一个明智的解决方案!
  • 安装最新的内部版本,您的问题应该会消失。

标签: vb.net uwp visual-studio-2017 uwp-xaml visual-studio-community


【解决方案1】:

感谢您的反馈。这是一个已修复的已知问题。正如@Justin XL 所说,您可以将系统更新为Windows 10 Insider Preview Build 16251 以解决此问题。这是现在的最新版本。升级后,您可能需要清理和重建项目并重新打开页面,然后TextBox 应该能够在 XAML 设计器中显示错误。

【讨论】:

    猜你喜欢
    • 2021-04-21
    • 1970-01-01
    • 2022-06-13
    • 2020-01-16
    • 2019-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多