【问题标题】:Project WPF .Net 3.5 in visual studio 2010 cause errorVisual Studio 2010 中的项目 WPF .Net 3.5 导致错误
【发布时间】:2012-06-29 14:12:06
【问题描述】:

我在创建空白 wpf .Net 3.5 项目时遇到问题。 Visual Studio 抛出错误并停止工作。这很奇怪,因为当我在 .Net 3.5 中创建其他项目(如 Windows 窗体)时,它可以正常工作(我也在其他 .Net 框架中测试过,没有错误)。
这是复制的错误详细信息:

  System.ArgumentException
  Type universe cannot resolve assembly: System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
  at System.Reflection.Adds.TypeNameParser.DetermineAssembly(AssemblyName assemblyName, Module defaultTokenResolver, ITypeUniverse universe)
  at System.Reflection.Adds.TypeNameParser.<>c__DisplayClass2.<ParseTypeName>b__0(AssemblyName assemblyName)
  at System.TypeNameParser.ResolveAssembly(String asmName, Func`2 assemblyResolver, Boolean throwOnError, StackCrawlMark& stackMark)
  at System.TypeNameParser.ConstructType(Func`2 assemblyResolver, Func`4 typeResolver, Boolean throwOnError, Boolean ignoreCase, StackCrawlMark& stackMark)
  at System.TypeNameParser.GetType(String typeName, Func`2 assemblyResolver, Func`4 typeResolver, Boolean throwOnError, Boolean ignoreCase, StackCrawlMark& stackMark)
  at System.Type.GetType(String typeName, Func`2 assemblyResolver, Func`4 typeResolver, Boolean throwOnError)
  at System.Reflection.Adds.TypeNameParser.ParseTypeName(ITypeUniverse universe, Module module, String input, Boolean throwOnError)
  at Microsoft.MetadataReader.UnresolvedTypeName.ConvertToType(ITypeUniverse universe, Module moduleContext)
  at Microsoft.MetadataReader.MetadataExtensionsPolicy20.TryTypeForwardResolution(MetadataOnlyAssembly assembly, String fullname, Boolean ignoreCase)
  at Microsoft.MetadataReader.MetadataOnlyAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
  at Microsoft.MetadataReader.MetadataOnlyAssembly.GetType(String name)
  at Microsoft.Windows.Design.Metadata.ReflectionMetadataContext.GetAssemblyType(Reflectable`1 assembly, String typeName)
  at MS.Internal.Metadata.ClrAssembly.GetType(String typeName)
  at Microsoft.Windows.Design.Metadata.ReflectionMetadataContext.LoadType(String typeName)
  at Microsoft.Windows.Design.Metadata.ReflectionMetadataContext.GetType(String fullName)
  at Microsoft.Windows.Design.Metadata.ReflectionMetadataContext.GetType(String fullName)
  at Microsoft.Windows.Design.Metadata.IdentifierExtensionImplementations.GetType(IMetadataContext scope, TypeIdentifier typeId)
  at MS.Internal.Design.Metadata.Xaml.XamlAssembly.get_XmlNamespaceCompatibilityMappings()
  at Microsoft.Windows.Design.Metadata.Xaml.XamlExtensionImplementations.GetXmlNamespaceCompatibilityMappings(IAssemblyMetadata sourceAssembly)
  at Microsoft.Windows.Design.Metadata.Xaml.XamlExtensions.GetXmlNamespaceCompatibilityMappings(IAssemblyMetadata source)
 at MS.Internal.Design.Metadata.ReflectionProjectNode.BuildSubsumption()
 at MS.Internal.Design.Metadata.ReflectionProjectNode.SubsumingNamespace(Identifier identifier)
 at MS.Internal.Design.Markup.XmlElement.BuildScope(PrefixScope parentScope, IParseContext context)
 at MS.Internal.Design.Markup.XmlElement.ConvertToXaml(XamlElement parent, PrefixScope parentScope, IParseContext context, IMarkupSourceProvider provider)
 at MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlSourceDocument.FullParse(Boolean convertToXamlWithErrors)
 at MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlSourceDocument.get_RootItem()
 at Microsoft.Windows.Design.DocumentModel.Trees.ModifiableDocumentTree.get_ModifiableRootItem()
 at Microsoft.Windows.Design.DocumentModel.MarkupDocumentManagerBase.get_LoadState()
 at MS.Internal.Host.PersistenceSubsystem.Load()
 at MS.Internal.Host.Designer.Load()
 at MS.Internal.Designer.VSDesigner.Load()
 at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedView.Load()
 at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedDesignerFactory.Load(IsolatedView view)
 at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view)
 at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view)
 at MS.Internal.Host.Isolation.IsolatedDesigner.Load()
 at MS.Internal.Designer.DesignerPane.LoadDesignerView()

图片:

我也尝试修复、卸载和重新安装 Visual Studio,但它仍然有错误。
任何帮助?
更新:只有在我打开 xaml 文件时才会出现错误。

【问题讨论】:

    标签: c# wpf visual-studio-2010 .net-3.5


    【解决方案1】:

    由于某种原因,您的 3.5 代码中引用了 system.XAML 4.0。卸载您的项目,然后对其进行编辑。找到其中包含 system.XAML 的行,然后删除它。重新加载项目后,您可以手动添加 3.5 版本。

    【讨论】:

    • 你能详细说明我能做什么吗?
    • 你试过我上面的步骤了吗?我以为我提供了解决问题所需的详细信息。如果我在上面写的内容令人困惑,请指出您想要更多解释的部分。
    • "卸载你的项目,然后编辑它"
    • 在解决方案资源管理器中右键单击您的项目。那里有一个“卸载项目”选项。用那个。卸载后,您可以再次右键单击该项目并选择“编辑项目”。您将以文本形式看到项目详细信息。搜索其中包含 system.XAML 的任何行。删除那些行。保存。然后再次右键单击该项目并选择“重新加载项目”。应该希望在那之后工作。
    • 我无法像你说的那样找到 system.xaml。看看我的项目:pastebin.com/gBKpKLVa。有什么问题吗?
    【解决方案2】:

    最后,我已经修好了。当我尝试更新 VS SP1 时,我收到了错误

    无法写入安装日志文件。验证温度 文件夹存在并且你可以写入它。

    然后我发现 %temp% 目录无法访问。然后我转到环境变量并更改 %temp% 路径(我以前从未接触过这个变量),并且设置 VS SP1 运行良好。此外,此 WPF 错误已修复。

    【讨论】:

      猜你喜欢
      • 2012-06-15
      • 2014-03-13
      • 2011-02-23
      • 1970-01-01
      • 2013-03-26
      • 2011-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多