Search code examples
vb.netuwpvisual-studio-2017uwp-xamlvisual-studio-community

Exception: Unable to create an instance of "TextBox" in Windows 10 Build 16232


I just did a clean install of Windows 10 Build 16232 and installed Visual Studio Community 2017 Preview with the UWP, .NET, and Xamarin "default" packages. I create a blank UWP app, placed a TextBox, and... Got an error.

Here's the XAML :

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

Now, for the error :

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()

Here's what I tried :

  • Debug x86
  • Debug ARM
  • Debug x64
  • Run as Admin
  • chkdsk
  • Reinstall Visual Studio
  • Reinstall Windows 10 Build 16232 (Slow Ring)
  • Install Visual Studio Community 2017
  • Uninstall Xamarin
  • Upgrade to Windows 10 Build 16241 (Fast Ring)

Every other common controls do work, but not that one. How do I make it work? The problem is only in the designer; I can compile the app just fine.


Solution

  • Thanks for your feedback. This is a known issue that has been fixed. As @Justin XL said, you can update your System to Windows 10 Insider Preview Build 16251 to solve this issue. This is the latest version now. After upgrading, you may need to clean and rebuild your project and reopen your pages, then the TextBox should be able to show in XAML Designer with on error.