WPF XAML Designer崩溃

时间:2012-12-17 20:50:27

标签: wpf xaml exception designer

我有一个Window,它唯一拥有的是TextBlock。每次我改变任何东西时,我都会遇到一些荒谬的设计师异常。我开始删除所有试图找到此错误的罪魁祸首。现在我什么都没有了,但设计师不断抛出异常。

<Window x:Class="Company.Product.Views.About"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="397"
    Width="658">
<TextBlock>Test</TextBlock>
</Window>
代码背后的代码:

/// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class About : Window
    {
        public About()
        {
            InitializeComponent();
        }
    }

如果我“单击此处重新加载设计器”窗口出现,但如果我修改了TextBlock的文本,我会得到一个异常

异常

System.ArgumentNullException
Value cannot be null.
   at System.RuntimeType.MakeGenericType(Type[] instantiation)
   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()
   at MS.Internal.Designer.PropertyEditing.PropertyInspector.OnSelectionChangedIdleForced(Object sender, EventArgs e)
   at System.Windows.Threading.DispatcherTimer.FireTick(Object unused)
   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)

我无法调试问题是什么,坦率地说,我感到很沮丧,因为这个简单的例子应该没​​有什么可以让设计师崩溃。有什么想法吗?

更新

重新安装,更新和重新加载后,问题暂时消失。现在问题又回来了。

实际上,我不确定问题是否已经消失。我还尝试了VS安全模式,/ resetsettings,并删除了VS文件夹中的几个缓存文件夹。

UPDATE2

Here's a screencast which shows the problem请原谅我的决议,我是肖像。

2 个答案:

答案 0 :(得分:0)

尝试在TextBlock属性中设置TextBlock.Text的内容:

<Window x:Class="Company.Product.Views.About"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="397"
Width="658">
     <TextBlock Text="Test"/>
</Window>

也许这就是问题。

答案 1 :(得分:0)

好吧,我相信我解决了这个问题。我创建了一个新的可执行项目,复制了旧的可执行项目,并尝试逐个删除或添加项目,以找出该项目的特殊之处。

事实证明,我正在通过Actipro引用几个第三方库。之前,我已经升级了库并将它们复制到/ lib文件夹并从那里引用它们。其中一个参考文献被遗忘了,我相信它是针对GAC而不是/ lib文件夹中的旧版本。我想我基本上已经引用了两个不同版本的Actipro共享库。

删除对第三方库的旧版本的错误引用,并将其更新为其他版本的正确版本后,问题已消失

奇怪的是,有问题的窗口没有使用该库中的组件或任何内容。可能是它试图解决库内的附加属性(来自堆栈跟踪)。