问题描述
System.NullReferenceException未将对象引用设置到对象的实例。在Microsoft.Windows.Design.Platform.SilverlightMetadataContext.SilverlightXamlExtensionImplementations.<GetXmlNamespaceCompatibilityMappings>d__8.MoveNext()在MS.Internal.Design.Metadata.ReflectionProjectNode.BuildSubsumption()在MS.Internal.Design.Metadata.ReflectionProjectNode.SubsumingNamespace(Identifieridentifier)在MS.Internal.Design.Markup.XmlElement.BuildScope(PrefixScopeparentScope,IParseContextcontext)在MS.Internal.Design.Markup.XmlElement.ConvertToXaml(XamlElementparent,PrefixScopeparentScope,IParseContextcontext,IMarkupSourceProviderprovider)在MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlSourceDocument.FullParse(BooleanconvertToXamlWithErrors)在MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlSourceDocument.get_RootItem()在Microsoft.Windows.Design.DocumentModel.Trees.ModifiableDocumentTree.get_ModifiableRootItem()在Microsoft.Windows.Design.DocumentModel.MarkupDocumentManagerBase.get_LoadState()在MS.Internal.Host.PersistenceSubsystem.Load()在MS.Internal.Host.Designer.Load()在MS.Internal.Designer.VSDesigner.Load()在MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedView.Load()在MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedDesignerFactory.Load(IsolatedViewview)在MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactoryfactory,IsolatedViewview)在MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactoryfactory,IsolatedViewview)在MS.Internal.Host.Isolation.IsolatedDesigner.Load()在MS.Internal.Designer.DesignerPane.LoadDesignerView()
解决方案
解决方案二:
参考
解决方案三:
如果自定义的控件放到设计窗口就报这类问题,那么很可能你的自定义控件的初始化部分或者Loaded事件处理部分有bug,平常测试不严格。大多数是Loaded时的问题,因为许多重要的业务逻辑初始化操作在这里执行。这里,应该写privatevoidUserControl_Loaded(objectsender,RoutedEventArgse){if(DesignerProperties.IsInDesignTool)return;.........}
这样在设计时避免执行不应该进行的操作。