Skip to content

[Question] DataGrid and System.Reflection.MissingMetadataException: 'Windows.Foundation.IReference`1<Double>' #4254

Open
@omikhailov

Description

@omikhailov

Hello!

I have the following problem: I changed hardware, installed the latest Windows updates and also updated the WCT and WinUI 2 packages, and now after starting the application in Release mode, it fails. In Debug mode with enabled Optimize Code and .Net Native Toolchain options, the following exception is thrown in GetXamlTypeByType() within XamlTypeInfo.g.cs :

System.Reflection.MissingMetadataException
  HResult=0x80131543
  Message=Windows.Foundation.IReference`1<Double>

Call Stack:
 	[External Code]	
 	System.Private.Interop.dll!System.Runtime.InteropServices.McgTypeHelpers.McgFakeMetadataType.GUID.get() Line 134	C#
 	System.Private.Reflection.Core.dll!System.Reflection.Runtime.TypeInfos.RuntimeTypeInfo.IsAssignableFrom(System.Type c) Line 274	C#
	System.Private.Reflection.Core.dll!System.Reflection.Runtime.TypeInfos.RuntimeTypeInfo.IsAssignableFrom(System.Reflection.TypeInfo typeInfo) Line 264	C#
 	Microsoft.UI.Xaml.Markup.dll!Microsoft.UI.Xaml.Markup.XamlReflectionType.XamlReflectionType(System.Type underlyingType)	Unknown
 	Microsoft.UI.Xaml.Markup.dll!Microsoft.UI.Xaml.Markup.ReflectionXamlMetadataProvider.getXamlType(System.Type typeID)	Unknown
	Common.ViewLayer.dll!Common.ViewLayer.Common_ViewLayer_XamlTypeInfo.XamlTypeInfoProvider.GetXamlTypeByType(System.Type type) Line 79	C#
 	Common.ViewLayer.dll!Common.ViewLayer.Common_ViewLayer_XamlTypeInfo.XamlMetaDataProvider.GetXamlType(System.Type type) Line 40	C#
 	Hamburger.exe!Hamburger.Hamburger_XamlTypeInfo.XamlTypeInfoProvider.CheckOtherMetadataProvidersForType(System.Type type) Line 1965	C#
 	Hamburger.exe!Hamburger.Hamburger_XamlTypeInfo.XamlTypeInfoProvider.GetXamlTypeByType(System.Type type) Line 133	C#
 	Hamburger.exe!Hamburger.App.GetXamlType(System.Type type) Line 39	C#
 	Hamburger.McgInterop.dll!Windows.UI.Xaml.Markup.IXamlMetadataProvider__Impl.Vtbl.GetXamlType__n(System.IntPtr pComThis, System.Type__Impl.UnsafeType unsafe_type, void** unsafe_result__retval)	C#
 	[External Code]	
 	System.Private.Interop.dll!System.Runtime.InteropServices.McgMarshal.ActivateInstance(string typeName) Line 1252	C#
 	Hamburger.McgInterop.dll!Microsoft.UI.Xaml.Controls.XamlControlsResources.XamlControlsResources()	C#
 	Hamburger.exe!Hamburger.Hamburger_XamlTypeInfo.XamlTypeInfoProvider.Activate_0_XamlControlsResources() Line 549	C#
 	Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.dll!Microsoft.Toolkit.Uwp.UI.Controls.Microsoft_Toolkit_Uwp_UI_Controls_DataGrid_XamlTypeInfo.XamlUserType.ActivateInstance() Line 2662	C#
 	Hamburger.McgInterop.dll!__Interop.ReverseComStubs.Stub_12(object __this, void** unsafe_result__retval, System.IntPtr __methodPtr)	C#
 	Hamburger.McgInterop.dll!Windows.UI.Xaml.Markup.IXamlType__Impl.Vtbl.ActivateInstance__n(System.IntPtr pComThis, void** unsafe_result__retval)	C#

Default.rd.xml has following entries:

<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
  <Application>
    <Assembly Name="*Application*" Dynamic="Required All" />
    
    <Type Name="Windows.Foundation.TypedEventHandler{Microsoft.UI.Xaml.Controls.NavigationView,Microsoft.UI.Xaml.Controls.NavigationViewItemInvokedEventArgs}" MarshalObject="Public" />

    <Type Name="Microsoft.UI.Xaml.Controls.NavigationView">
      <Event Name="ItemInvoked" Dynamic="Required"/>
    </Type>

    <Type Name="Windows.Foundation.TypedEventHandler{Microsoft.UI.Xaml.Controls.NavigationView,Microsoft.UI.Xaml.Controls.NavigationViewBackRequestedEventArgs}" MarshalObject="Public" />

    <Type Name="Microsoft.UI.Xaml.Controls.NavigationView">
      <Event Name="BackRequested" Dynamic="Required"/>
    </Type>

    <Type Name="Windows.UI.Xaml.Controls.Frame">
      <Method Name="GoBack" Dynamic="Required" />
    </Type>

    <Type Name="Microsoft.Toolkit.Uwp.UI.Controls.DataGridColumnEventArgs" Dynamic="Public" />

    <Type Name="Microsoft.Toolkit.Uwp.UI.Controls.DataGrid">
      <Event Name="Sorting" Dynamic="Required" />
      <Event Name="DoubleTapped" Dynamic="Required" />
      <Event Name="PreviewKeyDown" Dynamic="Required" />
      <Event Name="RightTapped" Dynamic="Required" />
      <Property Name="SelectedItem" Dynamic="Required" />
    </Type>
    
    <Type Name="Windows.UI.Xaml.Controls.Maps.MapControl">
      <Event Name="MapElementClick" Dynamic="Required" />
    </Type>

  </Application>
</Directives>

... and adding

<Type Name="Windows.Foundation.IReference`1{Double}" Dynamic="Required All" />

does not fix it.

Is it some known issue with the DataGrid?

Here is the link to .zip file with the app code in case if somebody would need to reproduce the issue: https://1drv.ms/u/s!AhdSWUTnA1aPgjz3Mp8UNmITf-zv?e=LEaD2m
I'm on Windows 10 Pro 19043.1237, Visual Studio 2019 16.11.3 and Ryzen 3600

Metadata

Metadata

Assignees

No one assigned

    Labels

    DataGrid 🔠Issues on DataGrid controlWinUI 💠Related to WinUI 3 Version or when paired with External can mean requires fix in WinUI 2/3.bug 🐛An unexpected issue that highlights incorrect behaviorexternal ⤴️Requires an update to an external dependency or due to code outside the Toolkit.help wantedIssues identified as good community contribution opportunitiesquestion ❔Issues or PR require more information

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions