Visual Studio 2015(社区)设计器显示空白Universal App的NullReferenceException

我对此感到有些沮丧,也许有人遇到了类似的问题或者想知道如何修复它。

我升级到Windows 10。
我安装了Visual Studio 2015社区。
我创建了一个新的解决方案,只有一个项目用于空白的通用Windows应用程序。 我正在使用C#。

问题:我试图在设计器中打开MainPage.xaml,但设计器不会加载。 我在设计器窗口中得到NullReferenceException 。 我尝试在Blend中打开它,结果相同。 正如Visual Studio建议的那样,我尝试关闭“选项”菜单中的“在XAML Designer中运行项目代码”function,但它没有帮助。

在设计器中打开其他xaml文件没有问题(WPF,Windows Phone 8或8.1 Universal应用程序都可以正常工作)。 该应用程序在本地计算机上运行,​​在模拟器中,只有设计者才能执行。

欢迎任何建议。

编辑

设计师窗口的例外情况:

 System.NullReferenceException Object reference not set to an instance of an object. at Microsoft.VisualStudio.DesignTools.Platform.Metadata.MetadataStore.GetTypeConverter(Type type) at Microsoft.VisualStudio.DesignTools.WindowsXamlDesigner.WindowsUIXamlDesignTimeProperties.ResolveImplementation(IPlatformMetadata platformMetadata, DesignTimePropertyId neutralProperty, IType declaringType, PropertyChangedCallback callback) at Microsoft.VisualStudio.DesignTools.WindowsXamlDesigner.WindowsUIXamlDesignTimeProperties.RegisterProperty(IPropertyId neutralPropertyKey, IType declaringType, PropertyChangedCallback callback) at Microsoft.VisualStudio.DesignTools.WindowsXamlDesigner.WindowsUIXamlCommonDesignTimeProperties.Initialize(WindowsUIXamlDesignTimeProperties designTimeProperties) at Microsoft.VisualStudio.DesignTools.WindowsXamlDesigner.WindowsUIXamlDesignTimeProperties..ctor(IPlatformTypes platformMetadata) at Microsoft.VisualStudio.DesignTools.UniversalXamlDesigner.UniversalXamlPlatformMetadata.CreateDesignTimeProperties() at Microsoft.VisualStudio.DesignTools.WindowsXamlDesigner.Metadata.WindowsUIXamlPlatformMetadata.Initialize() at Microsoft.VisualStudio.DesignTools.WindowsXamlDesigner.WindowsStoreXamlPlatform.Initialize() at Microsoft.VisualStudio.DesignTools.Platform.PlatformCreatorBase.CreatePlatform(IPlatformReferenceAssemblyResolver referenceAssemblyResolver) at Microsoft.VisualStudio.DesignTools.Designer.Project.ProjectContextManager.GetProjectContext(IHostProject project, IPlatform platform, Boolean create) at Microsoft.VisualStudio.DesignTools.Designer.Project.ProjectContextManager.GetSourceItemContext(IHostSourceItem sourceItem) at Microsoft.VisualStudio.DesignTools.Designer.DesignerService.CreateDesigner(IHostSourceItem item, IHostTextEditor editor, CancellationToken cancelToken) at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.RemoteDesignerService.c__DisplayClass12_0.b__0(CancellationToken cancelToken) at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.RemoteDesignerService.c__DisplayClass6_0`1.b__0() at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.Call.InvokeWorker() System.NullReferenceException Object reference not set to an instance of an object. Server stack trace: at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.WaitForCompletion(NestedCallContext nestedCallContext, BlockingCall call, WaitHandle timeoutSignal) at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.MarshalInSynchronous(Action action, Int32 targetApartmentId, CancellationToken cancelToken, CallModality callModality, String methodName, String filePath, Int32 lineNumber) at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.MarshalIn(Action action, Int32 targetApartmentId, CancellationToken cancelToken, CallSynchronizationMode syncMode, CallModality callModality, String methodName, String filePath, Int32 lineNumber) at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.ThreadMarshaler.MarshalIn(IRemoteObject targetObject, Action action, CancellationToken cancelToken, CallSynchronizationMode syncMode, CallModality callModality, ApartmentState apartmentState, String memberName, String filePath, Int32 lineNumber) at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.RemoteDesignerService.MarshalInWithCancellation[TResult](IRemoteCancellationToken remoteToken, Func`2 func, ApartmentState apartmentState) at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.RemoteDesignerService.Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.IRemoteDesignerService.CreateDesigner(IRemoteHostProject remoteProject, IRemoteHostSourceItem remoteItem, IRemoteHostTextEditor remoteEditor, IRemoteCancellationToken remoteToken) at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.IRemoteDesignerService.CreateDesigner(IRemoteHostProject remoteProject, IRemoteHostSourceItem remoteItem, IRemoteHostTextEditor remoteEditor, IRemoteCancellationToken cancelToken) at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.LocalDesignerService.CreateDesignerImpl(IRemoteDesignerService ds, IHostSourceItem item, IHostTextEditor editor, RemoteCancellationToken remoteCancelToken) at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.LocalDesignerService.c__DisplayClass14_0.b__0(IRemoteDesignerService ds, RemoteCancellationToken remoteToken) at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.LocalDesignerService.c__DisplayClass5_0`1.b__0(IRemoteDesignerService ds) at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.ThreadMarshaler.c__DisplayClass27_0`1.b__0() at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.Call.InvokeWorker() System.NullReferenceException Object reference not set to an instance of an object. at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.WaitForCompletion(NestedCallContext nestedCallContext, BlockingCall call, WaitHandle timeoutSignal) at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.MarshalOutSynchronous(Action action, Int32 targetApartmentId, WaitHandle aborted, WaitHandle timeoutSignal, CancellationToken cancelToken, String methodName, String filePath, Int32 lineNumber) at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.MarshalOut(Action action, Int32 targetApartmentId, WaitHandle aborted, CancellationToken cancelToken, CallSynchronizationMode syncMode, WaitHandle timeoutSignal, String methodName, String filePath, Int32 lineNumber) at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.ThreadMarshaler.MarshalOut[TValue](RemoteHandle`1 targetObject, Action action, CancellationToken cancelToken, CallSynchronizationMode syncMode, ApartmentState apartmentState, String methodName, String filePath, Int32 lineNumber) at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.ThreadMarshaler.MarshalOut[TValue](RemoteHandle`1 targetObject, Action`1 action, CancellationToken cancelToken, CallSynchronizationMode syncMode, ApartmentState apartmentState, String methodName, String filePath, Int32 lineNumber) at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.LocalDesignerService.MarshalOutWithCancellation[TResult](CancellationToken cancelToken, Func`3 func, ApartmentState apartmentState) at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.LocalDesignerService.Microsoft.VisualStudio.DesignTools.DesignerContract.IDesignerService.CreateDesigner(IHostSourceItem item, IHostTextEditor editor, CancellationToken cancelToken) at Microsoft.VisualStudio.DesignTools.DesignerContract.IsolatedDesignerService.IsolatedDesignerView.CreateDesignerViewInfo(CancellationToken cancelToken) 

如果你使用惠普,这对我有用:

删除系统 – >高级系统设置 – >环境变量中的“平台”环境变量…

就我而言,它说= HPD

您是否已启用设备进行开发? 在我启用它之前,我遇到了这个问题。

转到设置,然后更新和安全,然后转到开发人员。 选择开发者模式,你应该没问题。

完整的说明列表: https : //msdn.microsoft.com/en-us/library/windows/apps/dn706236.aspx

希望有所帮助!

我通过Visual Studio向Microsoft报告了这个问题,他们向我提出了2条建议,其中一条是有效的,所以我想我会在这里分享一下:

  1. 请查看以下已知问题,看看它是否有助于解决您的问题: https : //social.msdn.microsoft.com/Forums/en-US/f34da155-a4ad-4933-ba82-071de9c7c0b3/uwp-apps-fail-to -启动-和XAML的设计师崩溃,如果视觉工作室和窗口,商店的应用程序,是,两者兼而有之?论坛= Win10SDKToolsIssues

  2. 如果这没有用,请尝试以下操作(根据需要替换路径):

    icacls“c:\ Program Files(x86)\ Windows Kits \ 10 \ UnionMetadata \ Windows.winmd”/ grant * S-1-15-2-1:(RX)

请注意,我没有尝试第一个建议,因为它不适用于我,但第二个确实解决了我的问题。 确保在具有管理权限的命令行提示符中运行上述操作。

希望这会帮助其他人面对同样的问题。