olidev
olidev

Reputation: 20684

why I got this exception in xaml viewer of wpf?

I have this in xaml file:

<Window x:Class="TestTool.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:RecoConfigTool="clr-namespace:TestTool" Title="Window1" Height="300" Width="300">
<Grid>
        <ItemsControl ItemsSource="{Binding Parents}">
        </ItemsControl>
    </Grid>


    <Window.Resources>
        <DataTemplate DataType="{x:Type RecoConfigTool:Parent}">
            <StackPanel>
                <TextBox Text="{Binding Name}"/>
                <ListView ItemsSource="{Binding Childs}"/>
            </StackPanel>
        </DataTemplate>
        <DataTemplate DataType="{x:Type RecoConfigTool:Child}">
            <StackPanel Orientation="Horizontal">
                <TextBox Text="{Binding Name}"/>
                <TextBox>,</TextBox>
                <TextBox Text="{Binding Age}"/>
            </StackPanel>
        </DataTemplate>
    </Window.Resources>

</Window>

In design mode I always see the error of the xaml file but I can run it:

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.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.ClrMember1.Microsoft.Windows.Design.Metadata.Reflection.IReflectionMember.get_MemberInfo() at MS.Internal.Metadata.ClrType.Equals(Object obj) at System.Collections.Generic.ObjectEqualityComparer1.Equals(T x, T y)
at System.Collections.Concurrent.ConcurrentDictionary2.TryGetValue(TKey key, TValue& value) at Microsoft.Windows.Design.Metadata.Xaml.XamlExtensionImplementations.XamlMemberFor[TMember,TXaml](TMember member, Factory2 factory) at MS.Internal.Design.Metadata.Xaml.XamlType.d_7.MoveNext() at MS.Internal.Design.Metadata.Xaml.XamlType.d_0.MoveNext() at Microsoft.Windows.Design.Metadata.Xaml.XamlExtensionImplementations.d_7.MoveNext() at MS.Internal.VirtualModel.VirtualModelPropertyCollection.d_0.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) at MS.Internal.VirtualModel.VirtualModelPropertyCollection.GetEnumerator() at MS.Internal.Designer.PropertyEditing.Model.Properties.ModelPropertyMerger.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()

Upvotes: 3

Views: 1486

Answers (1)

Sebastian Edelmeier
Sebastian Edelmeier

Reputation: 4167

This is an issue M$ has already confirmed a Visual Studio SP1 bug. Uninstall SP1 and work happily ever after solved it for me. This is highly unsatisfactory and another blotch of shame on Microsofts gown, but what are the options?

Upvotes: 1

Related Questions