0

I have a winui3 project, and when I run it, it stops and show this

Call stack :

App1.dll!App1.App.InitializeComponent.AnonymousMethod__4_2(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e)

Debugging logs :

Exception thrown: 'System.ArgumentException' in WinRT.Runtime.dll
WinRT information: Not implemented

The program '[15308] App1.exe' has exited with code 4294967295 (0xffffffff).

Relevant code :

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;

namespace App1 {
    public sealed partial class App : Application {
        public static MainWindow m_window = new();

        public App() {
            // init
            this.InitializeComponent();
        }
    }
}

I found out that i can't run this line this.InitializeComponent();

1
  • You do not show the code about the exception. Could you please show a minimal, reproducible sample without private information? Commented Jul 17, 2024 at 1:01

1 Answer 1

0

You can try running the command to make sure the SDK has the components available:

Using the command-line or .NET CLI:

dotnet add package Microsoft.Windows.CsWinRT --version 2.0.8

This is needed plus additional components (based on the step 3): https://learn.microsoft.com/en-us/windows/apps/develop/platform/csharp-winrt/create-winrt-component-winui-cswinrt#author-your-cwinrt-component-using-the-windows-app-sdk

When creating the New Project, selecting the C++ Blank App, Packaged (WinUI 3 in Desktop) there should be a pch.h file where the WinRT is implemented:

#include <winrt/WinUIComponentCs.h>
#include <winrt/WinUIComponentCs.WinUIComponentCs_XamlTypeInfo.h>

The debug again

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you for your help , it works great on new project but i not on my old files , it said file .winmd not exist , do you have any ideas ?
@tribeti Is it necessary to do something for a new WinUI3 project?
@YangXiaoPo-MSFT the new project is Class Library (WinUI 3 in Desktop) template while the old one is Blank App template
@tribeti Could you please show a minimal, reproducible sample without private information?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.