ToastNotificationManager: Packaging Project to create the App ID only works within VS, not in published EXE

Emil

Member
Joined
Aug 24, 2021
Messages
6
Programming Experience
Beginner
Hello and thanks in advance,

i have a problem with a WPF Application using the ToastNotificationManager class:
The ToastNotificationManager class needs an App Identity.
I found this solution which seemed to work fine at the beginning:

In the section "Create an Identity for Your WPF App" Thomas described detailed how to add a Windows Application Packaging Project to my solution and set it as startup-project to have an Identity for my app.
This worked very well.
But only in the development Environment - if i start and test my application out of the Visual Studio 2019 environment.
As soon as i publish the app (using the produce-single-file option), it does not work anymore.

The errors pointed exactly in the direction that the App Identity was missing. The error occurred after calling the method "ToastNotificationManager.CreateToastNotifier ()".

Does anyone have an idea why the solution with setting the app id with the additional Application packaging project as start project does only work when calling the app from the Visual Studio Environment? And how i could solve it so that it runs even as published exe file ?

I have two ideas - but i'm a very beginner in C#, so i assume you have better ideas ;-)
1. Create an app ID manually. But i cannot find a good solution, how i can create such an id manually, seems to be rather complex
2. Maybe i could try to transform my app into an UWP application - then i would have no problem with the app ID. But i started with UWP and reached limits, so that i switched over to WPF. So maybe other parts of my applicatoin won't work if i switch back to UWP...

Thank you very much for your advice !

Best regards
Emanuel
 
How exactly did you publish the app as a single file? Did you embed the required manifest that is needed into that single file?
 
Thank you!
Good question...
I have two projects in my solution. The main project named "RebootNotifier". And then the project "AppIdentity" for getting the ID. The start project is "AppIdentity". It has a reference to "RebootNotifier".
I click with the right mouse button on "RebootNotifier" and select "Publish".
Then the publishing dialog opens. I can edit the profile settings and in "File publish options" i check "Produce single file".

But i think since i selected "Publish" in the project context i lost the connection to the "AppIdentity" project - is this right?
Would there be a way to publish without loosing the interaction to the "AppIdentity" project ?

When i right-click the entire solution there is no "publish" menu item...
 
If i right-click the AppIdentity project, the publishing options are different - i don't see a way to create a single file. And i need a single exe file.
1629812595898.png
 
Why not move your WPF code into your "AppIdentity" project?
 
To set the Application Identity you need a special type of project.
As described in the link i mentioned in the initial post:
Section "Create an Identity for Your WPF App"

Here an abstract of the important instructions:
"You can easily create an identity for your WPF app by packaging it as MSIX. To do this, just add a Windows Application Packaging Project to your solution. In the previous blog post we used the Windows Application Packaging Project already to target a specific windows version with WPF. This time we need that Packaging Project to get an identity"

So as far as i understand, both cannot be included in one project.
 
Ah. Forgive me. I thought that your AppIdentiy project was some special app that was not only n application, but also registered itself. I didn't realize that it was a simple MSIX package project. You will have to build the MSIX project and distribute the results of that, not your WPF project being compiled as a single executable.
 
Thank you! Yes, i think i got it now ;-)
So i have to go a completely different way.
Because i have to deliver one EXE that can be distributed to each user of our company. It is not an option that each user is installing the app manually. It has to be automatically distributed...

So i have a different idea:
The ToastNotificationManager.CreateToastNotifier() method (Windows.UI.Notifications) has a an overload:
CreateToastNotifier(String)
Where the parameter is the applicationId.
I thought it could not be very difficult to provide this parameter. But i found it is.
Do you have an idea how i can get - or maybe set - the correct application id and hand it over here to the .CreateToastNotifier() method?

I tried e.g.
Guid g = Guid.NewGuid();
and used g.toString()
But it doesn't work.
 
Last edited:
Because i have to deliver one EXE that can be distributed to each user of our company. It is not an option that each user is installing the app manually. It has to be automatically distributed...
I believe that an MSIX can be pushed by your IT department to all desktops and it will install automatically.

 

Latest posts

Back
Top Bottom