microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.33k stars 675 forks source link

WinUI 3 App - InitializeComponent Fails with WinRT Error and TypeInitializationException #9606

Open ghost opened 5 months ago

ghost commented 5 months ago

Describe the bug

This is a minimal WinUI 3 desktop app written in C++, hosting a WinUI 3 runtime component written in C# to display the Community Toolkit DataGrid.

When attempting to declare the DataGrid in a XAML file, InitializeComponent fails with the WinRT error 0x802B000A: 'Cannot create instance of type Microsoft.UI.Xaml.Controls.XamlControlsResources'.

When loading the DataGrid in the code-behind, a System.TypeInitializationException occurs, with the internal exception being a NullReferenceException: 'Object reference not set to an instance of an object'.

Steps to reproduce the bug

However, our host application is written in winrt/c++, which means we have to load the components as external winui3-runtime components.

Expected behavior

WinRT Error and TypeInitializationException should not occur.

Screenshots

No response

NuGet package version

None

Windows version

No response

Additional context

Any suggestions for resolving this issue?

github-actions[bot] commented 5 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

codendone commented 5 months ago

Can you attach a repro project?

ghost commented 5 months ago

DataGrid.zip

I have attached the sample

ghost commented 5 months ago

Any update on this?

Santhoshsf3897 commented 3 months ago

Any update on this?

Santhoshsf3897 commented 1 month ago

Any update on this?

Santhoshsf3897 commented 3 weeks ago

Any update on this?