C# - UWP AppInfo throws NotImplementedException

xFoondom 1 Reputation point
2021-04-04T18:36:58.673+00:00

I'm developing a C# WinForms app, using the UWP API. I'm attempting to read notifications programatically, and I have succeeded so far. However, whenever I call AppInfo from the UserNotification class, I get a NotImplementedException, no matter what property I read from AppInfo.

Does anyone have any suggestions?

I have only been able to find 1 answer to this question and it's not very useful, and also a few years old. This is a major roadblock in my project, any help is massively appreciated!

Thank you in advance.

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,836 questions
Universal Windows Platform (UWP)
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,285 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Nico Zhu (Shanghai Wicresoft Co,.Ltd.) 12,856 Reputation points
    2021-04-05T02:58:21.193+00:00

    Hello, Welcome to Micorosoft Q&A,

    UWP AppInfo throws NotImplementedException

    Derive the exception, it looks notification.AppInfo.DisplayInfo has not implemented for WinForm platform. For this scenario, we have a workaround for getting AppInfo with AppDiagnosticInfo api. Please refer the following code

    var list = await AppDiagnosticInfo.RequestInfoAsync();  
    var currentPackage = list.Where(o => o.AppInfo.PackageFamilyName == Package.Current.Id.FamilyName).FirstOrDefault();  
    if (currentPackage != null)  
    {  
        AppInfo currentAppInfo = currentPackage.AppInfo;  
        var display = currentAppInfo.DisplayInfo;  
    }  
    

    Update

    UserNotificationListener has no DualApiPartitionAttribute, it means it is not support for desktop app, I'm afraid you could not use desktop app to get all other app's notifications.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.