WindowsCommunityToolkit icon indicating copy to clipboard operation
WindowsCommunityToolkit copied to clipboard

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

Open omikhailov opened this issue 2 years ago • 13 comments

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

omikhailov avatar Sep 16 '21 15:09 omikhailov

Hello omikhailov, thank you for your interest in Windows Community Toolkit!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible.. Other community members may also answer the question and provide feedback 🙌

ghost avatar Sep 16 '21 15:09 ghost

Hi @omikhailov the project looks a bit complex, can you point us to the project that should be run (you can also just attach zip files to issues directly usually)?

What specific versions of the Toolkit and WinUI are you using as there are various previews and stable releases available at the moment?

michael-hawker avatar Sep 16 '21 17:09 michael-hawker

Hi, Michael!

Startup project is called Hamburger, and all projects within solution use Windows Community Toolkit 7.0.2 and WinUI 2.7

omikhailov avatar Sep 16 '21 18:09 omikhailov

This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost avatar Nov 03 '21 01:11 ghost

This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost avatar Nov 18 '21 04:11 ghost

This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost avatar Dec 03 '21 07:12 ghost

This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost avatar Dec 18 '21 10:12 ghost

This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost avatar Jan 02 '22 13:01 ghost

@Arlodotexe @XAML-Knight wonder if this repros for either of you? I don't think we've heard reports of this from anywhere else.

michael-hawker avatar Jan 11 '22 00:01 michael-hawker

Actually, just got a notification on another issue which appears to be very similar filed on the platform here: https://github.com/microsoft/microsoft-ui-xaml/issues/2545

@Sergio0694 do you remember context here? Did it go away targeting a newer platform version? @omikhailov have you tried updating to the latest SDK, Toolkit, and WinUI versions since?

michael-hawker avatar Jan 11 '22 00:01 michael-hawker

@omikhailov have you tried updating to the latest SDK, Toolkit, and WinUI versions since?

Just tried and it didn't resolve the issue as well as updating Windows to 19044.1415

omikhailov avatar Jan 11 '22 14:01 omikhailov

Confirming the runtime error in the Hamburger app.

XAML-Knight avatar Jan 11 '22 18:01 XAML-Knight

This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost avatar Jan 26 '22 19:01 ghost