windowsvisual-c++winui-3c++-winrtmidl

MIDL2011 error when trying to use INotifyPropertyChanged


I am currently trying to make a datatype for my List View in C++/WinRT. I have created an IDL file according to the documentation provided by Microsoft. When trying to compile the program it throws a MIDL2011 saying that "Microsoft.UI.XAML.Data.INotifyPropertyChanged" cannot be resolved. I am trying to compile so that it generates an implementation. I have tried replacing "Microsoft" with "Windows" and that did not work

My IDL file:

namespace Clankboard
{
    runtimeclass SoundlistItem : Microsoft.UI.XAML.Data.INotifyPropertyChanged
    {
        SoundlistItem(String soundName, String soundLocation, String soundLocationIcon, String soundKeybind, Boolean progressRingEnabled, String KeybindBtnForecolor);
        String SoundName;
        String SoundLocation;
        String SoundLocationIcon;
        String SoundKeybind;
        Boolean ProgressRingEnabled;
        String KeybindBtnForecolor;
    }
}

Solution

  • error MIDL2011 : [msg]unresolved type declaration [context]:, followed by a type name.

    In your IDL file, add an import directive for the IDL file(s) that contain the definitions of any type(s) that you reference that you've defined in your project.

    I suggest you could try to install the VSIX and let that take care of automatically referencing Windows namespace types for you.

    Refer to the links: https://learn.microsoft.com/en-us/windows/uwp/cpp-and-winrt-apis/intro-to-using-cpp-with-winrt#visual-studio-support-for-cwinrt-xaml-the-vsix-extension-and-the-nuget-package

    https://github.com/MicrosoftDocs/windows-dev-docs/issues/677

    As Simon said: you should use Microsoft.UI.Xaml.Data instead of Microsoft.UI.XAML.Data.