CommunityToolkit / WindowsCommunityToolkit

The Windows Community Toolkit is a collection of helpers, extensions, and custom controls. It simplifies and demonstrates common developer tasks building .NET apps with UWP and the Windows App SDK / WinUI 3 for Windows 10 and Windows 11. The toolkit is part of the .NET Foundation.
https://docs.microsoft.com/windows/communitytoolkit/
Other
5.87k stars 1.38k forks source link

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

Open omikhailov opened 3 years ago

omikhailov commented 3 years ago

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

ghost commented 3 years ago

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 🙌

michael-hawker commented 3 years ago

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?

omikhailov commented 3 years ago

Hi, Michael!

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

ghost commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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.

michael-hawker commented 2 years ago

@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 commented 2 years ago

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?

omikhailov commented 2 years ago

@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

XAML-Knight commented 2 years ago

Confirming the runtime error in the Hamburger app.

ghost commented 2 years ago

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.