选择新的WPF项目时WPF设计器错误

时间:2010-07-12 10:36:53

标签: c# wpf

当我选择一个新的WPF项目时,我收到以下错误。

Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
   at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(String assemblyName, String typeName)
   at System.AppDomain.CreateInstance(String assemblyName, String typeName)
   at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName)
   at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName)
   at MS.Internal.Package.VSIsolationProviderService.CreateIsolationProvider(String identity, AssemblyReferenceProvider assemblyReferences, IEnumerable`1 assemblyFolders)
   at MS.Internal.Providers.VSDesignerContext.GetIsolationProvider(IServiceProvider provider, IVsHierarchy hierarchy, AssemblyReferenceProvider assemblyReferences)
   at MS.Internal.Providers.VSDesignerContext.Initialize(IServiceProvider provider, IVsHierarchy hierarchy, UInt32 itemid, Object docDataObj)
   at MS.Internal.Providers.VSDesignerContext..ctor(IServiceProvider provider, IVsWindowFrame frame, Object docDataObj)
   at MS.Internal.Providers.VSDesignerContext.GetContext(IServiceProvider services, IVsWindowFrame frame, Boolean createIfNotExist)
   at MS.Internal.Designer.DesignerPane.InitializeDesigner()

1 个答案:

答案 0 :(得分:0)

(来自http://www.designasp.net/blog/en/post/2009/03/29/XAML-designer-Loading-this-assembly-would-produce-a-different-grant-set-from-other-instances-%28Exception-from-HRESULT-0x80131401%29.aspx

如果在打开WPF编辑器时出现此错误,请尝试:

  1. 打开Visual Studio的第二个实例并尝试打开XAML。
  2. 关闭所有.xaml和.xml文件,关闭Visual Studio,重新打开它并打开.xaml文件。
  3. 禁用工具中的所有加载项 - >加载项管理器
  4. 在Visual Studio中“重置所有设置”。
  5. 安装有助于修复XAML设计器的CLR补丁(KB963676)。有一个来自微软的已知反馈表明这应该有所帮助。在此下载(https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=16827&wa=wsignin1.0)。 * .msu是Windows Vista或Windows Server 2008的补丁。* .exe适用于Windows XP或Windows Server 2003.即使您使用的是64位计算机,仍需要x86补丁,因为Visual Studio 2008是32位的应用
  6. 卸载所有Silverlight工具,运行时,SDK,Expression Blend。在此之后,修复Visual Studio。
  7. 重新安装Visual Studio和.NET Framework。
  8. 如果无效,则必须重新安装操作系统。