簡體   English   中英

WPF XAML設計器崩潰

[英]WPF XAML Designer Crashes

我有一個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

這是一個顯示問題的截屏視頻,請問我的分辨率是多少,我處於肖像狀態。

嘗試在TextBlock.Text屬性中設置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 Text="Test"/>
</Window>

也許這就是問題所在。

好吧,我相信我已經解決了這個問題。 我創建了一個新的可執行項目,將所有內容從舊項目復制到新項目,然后嘗試逐個刪除或添加項目,以了解該項目的特殊之處。

事實證明,我引用了Actipro的幾個第三方庫。 之前,我已經升級了庫並將它們復制到/ lib文件夾,並從那里引用它們。 不過,其中一個參考文獻被遺忘了,我相信它的目標是GAC中的較舊版本而不是/ lib文件夾。 我想我基本上引用了兩個不同版本的Actipro共享庫。

在刪除了對第三方庫的舊版本的錯誤引用,並將其更新為其他版本的正確版本之后,問題消失了

奇怪的是,相關窗口未使用該庫中的任何組件或任何東西。 可能是它試圖解析庫中的附加屬性(從堆棧跟蹤中)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM