【问题标题】:What causes the VS 2010 SP1 WPF Designer to crash?是什么导致 VS 2010 SP1 WPF 设计器崩溃?
【发布时间】:2012-04-26 10:08:16
【问题描述】:

在以下情况下,我们在 VS2010 WPF 设计器中的各种机器上遇到崩溃:

  • 已安装 VS 2010 SP1
  • 64 位 Windows 7
  • 参考 NHibernate.dll(版本 1.2.0.712)

要重现错误,请创建一个新的 WPF 解决方案,执行以下操作:

  • 创建新的 WPF 解决方案
  • 打开主窗口,添加一个文本框,设置一些静态文本
  • 添加对 FluentNhibernate.dll 版本 1.2.0.712 的引用
  • 清理并重建解决方案
  • 再次在设计器中打开主窗口,编辑文本
  • 在设计器中,单击窗口左侧,然后再次返回文本框

没有数据/命令绑定,没有引用 FluentNHibernate 功能或任何高度复杂的代码,只是在 MainWindow.xaml 中具有以下 XAML 的新 WPF 解决方案:

<Window x:Class="testWpfApplication2.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="800"
    Title="MainWindow" Height="350" >
  <Grid>
    <TextBox Text="yxcydfdssdfsdfdsfsdsddsasdyxcasd"  />
  </Grid>
</Window>

这是完整的 Stacktrace:

System.Reflection.TargetInvocationException
Exception has been thrown by the target of an invocation.
   at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)   
   at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)   
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)   
   at System.Delegate.DynamicInvokeImpl(Object[] args)   
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)   
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

System.NullReferenceException
Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUtil.GetRuntimeTypeVariable(Type type)   
   at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUtil.GetRuntimeType(Type type)   
   at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUtil.EnsureRuntimeType(Type type)   
   at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUtil.GetRuntimeType(Type type)   
   at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkType.TryGetRuntimeType()   
   at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUtil.EnsureRuntimeType(Type type)   
   at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkProvider.GetRuntimeType(Type reflectionType)   
   at MS.Internal.Package.VSIsolationProviderService.RemoteReferenceProxy.VsReflectionResolver.GetRuntimeType(Type reflectionType)   
   at Microsoft.Windows.Design.Metadata.ReflectionMetadataContext.CachingReflectionResolver.GetRuntimeType(Type reflectionType)   
   at Microsoft.Windows.Design.Metadata.ReflectionMetadataContext.Microsoft.Windows.Design.Metadata.IReflectionResolver.GetRuntimeType(Type reflectionType)   
   at MS.Internal.Metadata.ClrType.get_RuntimeMember()   
   at MS.Internal.Metadata.ClrMember`1.Microsoft.Windows.Design.Metadata.Reflection.IReflectionMember.get_MemberInfo()   
   at MS.Internal.Metadata.ClrType.Equals(Object obj)   at System.Collections.Generic.ObjectEqualityComparer`1.Equals(T x, T y)   
   at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)   
   at Microsoft.Windows.Design.Metadata.Xaml.XamlExtensionImplementations.<>c__DisplayClass5.<FindAttachableProperties>b__4(ITypeMetadata walkType)   
   at MS.Internal.Design.Metadata.Xaml.XamlType.<GetAllAttachableProperties>d__7.MoveNext()   
   at MS.Internal.Design.Metadata.Xaml.XamlType.<FindAttachableProperties>d__0.MoveNext()   
   at Microsoft.Windows.Design.Metadata.Xaml.XamlExtensionImplementations.<FindAttachableProperties>d__7.MoveNext()   
   at MS.Internal.VirtualModel.VirtualModelPropertyCollection.<GetUncachedProperties>d__0.MoveNext()   
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)   
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)   
   at MS.Internal.VirtualModel.VirtualModelPropertyCollection.GetEnumerator()  
   at MS.Internal.Designer.PropertyEditing.Model.Properties.ModelPropertyMerger.<GetFirstProperties>d__0.MoveNext()   
   at MS.Internal.Designer.PropertyEditing.Views.PropertyEntryReader.RedraftEntries(IPropertyViewManager viewManager, Selection selection, Boolean attachedOnly, IEventCodeBehindProxy eventCodeBehindProxy, CategoryList categoryList)   
   at MS.Internal.Designer.PropertyEditing.PropertyInspector.UpdateCategories(Selection selection, Boolean attachedOnly, IEntryReader entryReader)   
   at MS.Internal.Designer.PropertyEditing.PropertyInspector.RefreshPropertyList(Boolean attachedOnly)   
   at MS.Internal.Designer.PropertyEditing.PropertyInspector.OnSelectionChangedIdle()

MS 已确认这是一个 SP1 错误,但为了获得满意的结果,我需要了解更多有关此问题的信息...

是什么原因造成的,为什么只有在添加 FNH 时才会出现,为什么只有在从某个位置添加时才会出现(程序集相同 - 我们进行了逐字节比较)?没有 SP1,它可以工作...

【问题讨论】:

  • 我对此做的最后一件事是下载 FluentNHibernate 源代码(最新)并将其作为项目引用。这工作正常,所以基本上它必须与有问题的dll有关。 Visual Studio 是否对引用的 DLL 执行校验和计算之类的操作?
  • 您使用的任何控件都会发生这种情况吗?当窗口内没有控件时会发生这种情况吗?您是如何安装 NHibernate 的?

标签: wpf visual-studio-2010 crash designer


【解决方案1】:

我们有时会通过添加来解决这个问题

if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
                return;

在违规控件的加载事件中

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多