Desktop program and toast notification

  • Thread starter Thread starter Alex Cote
  • Start date Start date
A

Alex Cote

Guest
Hi,

I am trying to have the toast notification working in a desktop program (Windows Forms App) I have done in VB.NET VS2013 on a Windows 7 machine.

I now am using VS 2017 on a Windows 10 machine.

Searching through the web I was able to find an example (can't recall the author though) and have it working using a UWP project, but when I use the code in my Windows Forms App, it does not want to work. I get the following error: "error BC30652: Reference required to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken....."

I have tried to find out how I can add that reference but can't figure it out ...


The error disappear when I comment the line : MyToast.ExpirationTime = DateTime.Now.AddSeconds(4)

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim MySbXML As New StringBuilder()
MySbXML.Append("<toast><visual><binding template = ""ToastImageAndText01""><text id = ""1"" >")
MySbXML.Append("My Title" & vbCrLf & "My text here")
MySbXML.Append("</text></binding></visual></toast>")

Dim MyXmlDoc As New Windows.Data.Xml.Dom.XmlDocument()
MyXmlDoc.LoadXml(MySbXML.ToString())
Dim MyToast = New ToastNotification(MyXmlDoc)
'MyToast.ExpirationTime = DateTime.Now.AddSeconds(4)

Dim MyNotifier As ToastNotifier = ToastNotificationManager.CreateToastNotifier
MyNotifier.Show(MyToast)

Catch ex As Exception
MsgBox(ex.StackTrace & vbNewLine & ex.Message)
End Try
End Sub

Any idea ... or anyone with an example of working Toast Notification in VB.NET Windows Forms App ... would like to use that feature but don't want to redo the program for it :)

Continue reading...
 
Back
Top