WindowsAppSDK: Can't Send App notifications from (Admin) Console app using Windows apps sdk
Describe the bug
Can’t Send App notifications from Console app using Windows apps sdk
Exception is thrown:
System.TypeInitializationException: The type initializer for 'WinRT.ActivationFactory1' threw an exception. ---> System.Runtime.InteropServices.COMException (0x80040154): Class not registered (0x80040154 (REGDB_E_CLASSNOTREG)) at WinRT.BaseActivationFactory..ctor(String typeNamespace, String typeFullName) at WinRT.ActivationFactory
1…cctor()
— End of inner exception stack trace —
at Microsoft.Windows.AppNotifications.Builder.AppNotificationBuilder…ctor()
at Program.<Main>$(String[] args) in C:\Users\kwodarc\MyRepos\BugSandBox\ConsoleApp1\Program.cs:line 14
Steps to reproduce the bug
Create Console app and use latest windows apps sdk pacage and copy paste the following code and run:
// See https://aka.ms/new-console-template for more information
using Microsoft.Windows.AppNotifications.Builder;
using Microsoft.Windows.AppNotifications;
Console.WriteLine("Send Toast ?");
Console.ReadLine();
try
{
var appNotification = new AppNotificationBuilder()
.AddArgument("action", "ToastClick")
.AddText("Test Toast")
.AddText("This is an example message")
.BuildNotification();
AppNotificationManager.Default.Show(appNotification);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
Console.ReadLine();
.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.756" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.230811000-preview2" />
</ItemGroup>
</Project>
Expected behavior
toast sent
Screenshots
NuGet package version
WinUI 3 - Windows App SDK 1.4 Preview 1: 1.4.230628000-preview1
Windows version
Windows 11 (22H2): Build 22621.2134
Additional context
No response
About this issue
- Original URL
- State: open
- Created 10 months ago
- Comments: 19 (3 by maintainers)
As a drive-by note, I bet that this thread and #3816 could both be duped to #3595, and just turn #3595 into the feature request thread.
In #137 it was mentioned that notifications from admin apps should just work - I’m not sure if that ever actually was supported, or regressed recently, or what exactly. /cc @andrewleader for confirmation.