简体   繁体   中英

Project WPF .Net 3.5 in visual studio 2010 cause error

I have the problem when I create blank wpf .Net 3.5 project. Visual studio has throw an error and stop working. This is very strange because when I created other project in .Net 3.5 like windows form, it worked (aslo I have tested in other .Net framework without error).
Here is the copied error detail:

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

Image:

在此处输入图片说明 Also I tried repairing, uninstalling and reinstalling Visual Studio but it still has error.
Any help?
Update : error is only occurring when I open xaml file.

For some reason there is a reference to system.XAML 4.0 in your 3.5 code. Unload your project, and then edit it. Find the line that has the system.XAML in it, and get rid of it. You can add the 3.5 version in manually after you reload your project.

Finnaly, I have fixed it. When I tried to update VS SP1, I received the error

The installation log file could not be written. Verify that the Temp folder exists and that you can write to it.

Then I recognize the %temp% directory doesn't access. Then I go to environment variables and change %temp% path (I never touch this variable before), and the setup VS SP1 worked well. Also, this WPF error is fixed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM