WPF设计器,目标x64平台:Microsoft.MetadataReader.UnresolvedAssemblyException

时间:2016-03-14 18:10:19

标签: c# wpf xaml designer

所以我有一个WPF应用程序,由于硬件使用,我必须为x64和x86创建它。但是当我将目标平台更改为x64并尝试打开.xaml文件时,它会在设计器中显示以下错误消息。

当我将它改回任何CPU时,没关系,我让设计师回来了。在这两个平台目标中,应用运行良好。

Microsoft.MetadataReader.UnresolvedAssemblyException
Type universe cannot resolve assembly: System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
   at Microsoft.MetadataReader.SimpleUniverse.Microsoft.MetadataReader.ITypeUniverse.ResolveAssembly(AssemblyName name)
   at Microsoft.MetadataReader.SimpleUniverse.Microsoft.MetadataReader.ITypeUniverse.ResolveAssembly(Module scope, Token tokenAssemblyRef)
   at Microsoft.MetadataReader.MetadataOnlyModule.ResolveTypeRef(ITypeReference typeReference)
   at Microsoft.MetadataReader.MetadataOnlyTypeReference.GetResolvedTypeWorker()
   at Microsoft.MetadataReader.TypeProxy.GetResolvedType()
   at Microsoft.MetadataReader.TypeProxy.GetHashCode()
   at System.Collections.Generic.ObjectEqualityComparer`1.GetHashCode(T obj)
   at System.Collections.Concurrent.ConcurrentDictionary`2.TryGetValue(TKey key, TValue& value)
   at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.XamlPlatformMetadata.GetType(Type type)
   at Microsoft.VisualStudio.DesignTools.Platform.Metadata.TypeResolver.GetType(String key, IAssembly assembly, Type type)
   at Microsoft.VisualStudio.DesignTools.Platform.Metadata.TypeResolver.GetType(Type type)
   at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.XamlProjectMetadata.GetType(Type type)
   at Microsoft.VisualStudio.DesignTools.Platform.Metadata.ProjectContextType.Cache()
   at Microsoft.VisualStudio.DesignTools.Platform.Metadata.ProjectContextType.Initialize(IXmlNamespace xmlNamespace, Type type)
   at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockType.Initialize(IXmlNamespace xmlNamespace, Type type)
   at Microsoft.VisualStudio.DesignTools.Platform.Metadata.TypeResolver.GetType(String key, IAssembly assembly, Type type)
   at Microsoft.VisualStudio.DesignTools.Platform.Metadata.TypeResolver.GetType(Type type)
   at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.XamlProjectMetadata.GetType(Type type)
   at Microsoft.VisualStudio.DesignTools.Platform.Metadata.ProjectContextType.Cache()
   at Microsoft.VisualStudio.DesignTools.Platform.Metadata.ProjectContextType.Initialize(IXmlNamespace xmlNamespace, Type type)
   at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockType.Initialize(IXmlNamespace xmlNamespace, Type type)
   at Microsoft.VisualStudio.DesignTools.Platform.Metadata.TypeResolver.GetType(String key, IAssembly assembly, Type type)
   at Microsoft.VisualStudio.DesignTools.Platform.Metadata.TypeResolver.GetType(Type type)
   at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.XamlProjectMetadata.GetType(Type type)
   at Microsoft.VisualStudio.DesignTools.Platform.Metadata.ProjectContextType.Cache()
   at Microsoft.VisualStudio.DesignTools.Platform.Metadata.ProjectContextType.Initialize(IXmlNamespace xmlNamespace, Type type)
   at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockType.Initialize(IXmlNamespace xmlNamespace, Type type)
   at Microsoft.VisualStudio.DesignTools.Platform.Metadata.TypeResolver.GetType(String key, IAssembly assembly, Type type)
   at Microsoft.VisualStudio.DesignTools.Platform.Metadata.TypeResolver.GetType(ClrNamespaceIdentifier clrNamespaceIdentifier, String typeName)
   at Microsoft.VisualStudio.DesignTools.Platform.Metadata.TypeResolver.GetType(IXmlNamespace xmlNamespace, String typeName)
   at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.XamlProjectMetadata.GetType(IXmlNamespace xmlNamespace, String typeName)
   at Microsoft.VisualStudio.DesignTools.Markup.DocumentXmlnsDefinitionMap.GetType(IXmlNamespace xmlNamespace, String typeName)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlTypeHelper.ResolveTypeInternal(ITypeResolver typeResolver, IXmlNamespaceTypeResolver xmlNamespaceTypeResolver, XmlNamespace xmlNamespace, String typeName)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlTypeHelper.ResolveType(ITypeResolver typeResolver, IXmlNamespaceTypeResolver xmlNamespaceTypeResolver, XmlNamespace xmlNamespace, String typeName, Boolean inMarkupExtension)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlTypeHelper.GetTypeId(ITypeResolver typeResolver, DocumentXmlnsDefinitionMap documentNamespaces, XmlNamespace xmlNamespace, String typeName, Boolean instantiateUnrecognizedTypes, Boolean inMarkupExtension)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlTypeHelper.GetTypeId(XamlParserContext parserContext, ITextLocation lineInformation, XmlNamespace xmlNamespace, String typeName, Boolean inMarkupExtension)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlTypeHelper.GetTypeId(XamlParserContext parserContext, ITextLocation lineInformation, IXmlNamespaceResolver xmlNamespaceResolver, String fullTypeName, Boolean inMarkupExtension)
   at Microsoft.VisualStudio.DesignTools.Markup.MarkupExtensionParser.ParseMarkupExtension(XamlParserContext parserContext, ITextLocation lineInformation, IDocumentNodeReference nodeReference, IXmlNamespaceResolver xmlNamespaceResolver, IType valueType, String text, Int32 attributeValueOffset)
   at Microsoft.VisualStudio.DesignTools.Markup.MarkupExtensionParser.GetPropertyValue(XamlParserContext parserContext, ITextLocation lineInformation, IDocumentNodeReference nodeReference, IXmlNamespaceResolver xmlNamespaceResolver, TypeConverter typeConverter, IType valueTypeId, String value, Boolean removeEscapeCharacters, XmlAttribute attribute)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlParser.SetProperty(XamlParserContext parserContext, ITextLocation lineInformation, DocumentCompositeNodeReference nodeReference, XmlElementReference xmlElementReference, XmlAttribute attribute, IProperty propertyKey)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlParser.AddPropertiesAndChildren(XamlParserContext parserContext, DocumentCompositeNodeReference nodeReference, XmlElementReference xmlElementReference, XmlElement xmlElement, Predicate`1 propertyFilter)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlParser.ParseStyleOrTemplate(XamlParserContext parserContext, IDocumentNodeReference nodeReference, ITypeId type, XmlElementReference xmlElementReference, XmlElement xmlElement)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlParser.ParseElementContent(XamlParserContext parserContext, IDocumentNodeReference nodeReference, IType typeId, XmlElementReference xmlElementReference, XmlElement xmlElement)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlParser.ParseElement(XamlParserContext parserContext, IDocumentNodeReference nodeReference, XmlElementReference xmlElementReference, XmlElement xmlElement, DocumentNode& node)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlParser.ParseContent(XamlParserContext parserContext, IDocumentNodeReference nodeReference, XmlElementReference xmlElementReference, XmlElement xmlElement, IProperty childProperty, TypeConverter textTypeConverter, ITypeId textType, PropertyHandling propertyHandling)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlParser.AddPropertiesAndChildren(XamlParserContext parserContext, DocumentCompositeNodeReference nodeReference, XmlElementReference xmlElementReference, XmlElement xmlElement, Predicate`1 propertyFilter)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlParser.AddPropertiesAndChildren(XamlParserContext parserContext, DocumentCompositeNodeReference nodeReference, XmlElementReference xmlElementReference, XmlElement xmlElement)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlParser.ParseCompositeElement(XamlParserContext parserContext, IDocumentNodeReference nodeReference, IType typeId, XmlElementReference xmlElementReference, XmlElement xmlElement)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlParser.ParseElementContent(XamlParserContext parserContext, IDocumentNodeReference nodeReference, IType typeId, XmlElementReference xmlElementReference, XmlElement xmlElement)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlParser.ParseElement(XamlParserContext parserContext, IDocumentNodeReference nodeReference, XmlElementReference xmlElementReference, XmlElement xmlElement, DocumentNode& node)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlParser.ParseContent(XamlParserContext parserContext, IDocumentNodeReference nodeReference, XmlElementReference xmlElementReference, XmlElement xmlElement, IProperty childProperty, TypeConverter textTypeConverter, ITypeId textType, PropertyHandling propertyHandling)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlParser.AddPropertiesAndChildren(XamlParserContext parserContext, DocumentCompositeNodeReference nodeReference, XmlElementReference xmlElementReference, XmlElement xmlElement, Predicate`1 propertyFilter)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlParser.AddPropertiesAndChildren(XamlParserContext parserContext, DocumentCompositeNodeReference nodeReference, XmlElementReference xmlElementReference, XmlElement xmlElement)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlParser.ParseCompositeElement(XamlParserContext parserContext, IDocumentNodeReference nodeReference, IType typeId, XmlElementReference xmlElementReference, XmlElement xmlElement)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlParser.ParseElementContent(XamlParserContext parserContext, IDocumentNodeReference nodeReference, IType typeId, XmlElementReference xmlElementReference, XmlElement xmlElement)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlParser.ParseRootElement(XamlParserContext parserContext, XmlElementReference xmlElementReference, XmlElement xmlElement)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlParser.Parse(XamlParserContext parserContext, XmlDocumentReference xmlDocumentReference, XmlDocument xmlDocument)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlParser.ParseInternal(XamlParserContext parserContext)
   at Microsoft.VisualStudio.DesignTools.Markup.XamlLanguageService.ParseDocument(CancellationToken cancelToken)
   at Microsoft.VisualStudio.DesignTools.Markup.MarkupDocument..ctor(IDocumentContext documentContext, ITypeId expectedRootType, ITextBuffer textBuffer, Encoding documentEncoding, IMarkupLanguageService languageService, CancellationToken cancelToken)
   at Microsoft.VisualStudio.DesignTools.Designer.Documents.SceneMarkupDocument..ctor(IDocumentContext documentContext, IUndoService undoService, ITypeId expectedRootType, ITextBuffer textBuffer, Encoding documentEncoding, IMarkupLanguageService languageService, CancellationToken cancelToken)
   at Microsoft.VisualStudio.DesignTools.Designer.DocumentViewContext.CreateMarkupDocument(ISourceItemContext sourceItem, IHostTextBuffer textBuffer, Encoding encoding, CancellationToken cancelToken)
   at Microsoft.VisualStudio.DesignTools.Designer.DocumentViewContext.CreateDocument(ISourceItemContext sourceItem, CancellationToken cancelToken, Boolean isReadOnly, Boolean cloneBufferToStandalone, Boolean suppressUI, SceneDocument originalSceneDocument)
   at Microsoft.VisualStudio.DesignTools.Designer.DocumentViewContext.OpenDocument(ISourceItemContext sourceItem, CancellationToken cancelToken, Boolean isReadOnly, Boolean suppressUI)
   at Microsoft.VisualStudio.DesignTools.Designer.Project.ProjectContextBase.OpenProjectDocument(ISourceItemContext sourceItem, Boolean suppressUI)
   at Microsoft.VisualStudio.DesignTools.XamlDesigner.DocumentModel.XamlProjectContext.FindApplicationDocumentForContext(XamlProjectContext xamlProjectContext)
   at Microsoft.VisualStudio.DesignTools.XamlDesigner.DocumentModel.XamlProjectContext.get_LocalApplication()
   at Microsoft.VisualStudio.DesignTools.XamlDesigner.DocumentModel.XamlProjectContext.get_Application()
   at Microsoft.VisualStudio.DesignTools.Designer.Documents.SceneDocument.GetApplicationDocument(IProjectContext activeContext)
   at Microsoft.VisualStudio.DesignTools.Designer.View.ViewRootResolver.GetView(IDocumentRoot documentRoot, Boolean hidden)
   at Microsoft.VisualStudio.DesignTools.Designer.DocumentViewContext.CreateAndOpenViewInternal(SceneDocument document, CancellationToken cancelToken, Boolean activate, Boolean ensureOpenInHost)
   at Microsoft.VisualStudio.DesignTools.Designer.DesignerService.CreateDesigner(IHostSourceItem item, IHostTextEditor editor, CancellationToken cancelToken)
   at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.RemoteDesignerService.<>c__DisplayClass12_0.<Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.IRemoteDesignerService.CreateDesigner>b__0(CancellationToken cancelToken)
   at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.RemoteDesignerService.<>c__DisplayClass6_0`1.<MarshalInWithCancellation>b__0()
   at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.Call.InvokeWorker()

System.Reflection.TargetInvocationException
Type universe cannot resolve assembly: System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.

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.<Microsoft.VisualStudio.DesignTools.DesignerContract.IDesignerService.CreateDesigner>b__0(IRemoteDesignerService ds, RemoteCancellationToken remoteToken)
   at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.LocalDesignerService.<>c__DisplayClass5_0`1.<MarshalOutWithCancellation>b__0(IRemoteDesignerService ds)
   at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.ThreadMarshaler.<>c__DisplayClass28_0`1.<MarshalOut>b__0()
   at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.Call.InvokeWorker()

System.Reflection.TargetInvocationException
Type universe cannot resolve assembly: System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
   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)

起初,一些错误也出现了(虽然它仍然可以运行)。那些错误告诉我,我也有一些可移植的库设置为x64。所以我在Configuration Manager中将它们分别设置回任何CPU。然后出现了一些关于不匹配的警告,但是在干净的构建之后很快就消失了。

也许值得注意的是,样式是在不同的程序集中,但是将其更改为任何CPU或x64也没有任何影响。我还使用Metro作为我的窗口的基类。

0 个答案:

没有答案