Action Heinz
Action Heinz

Reputation: 744

Error when adding activated event to toast notification

I have added a toast notification to my program, compiled it, and it works as expected.

The toast notification is shown.

After that I added the activated event:

toast.Activated += toast_Activated;

void toast_Activated(ToastNotification sender, object args)
{

}

When trying to compile this code I get following error:

Property, indexer, or event 'Windows.UI.Notifications.ToastNotification.Activated' is not supported by the language; try directly calling accessor method 'Windows.UI.Notifications.ToastNotification.add_Activated(Windows.Foundation.TypedEventHandler)' or 'Windows.UI.Notifications.ToastNotification.remove_Activated(System.Runtime.InteropServices.WindowsRuntime.EventRegistrationToken)'

What am I doing wrong?

Upvotes: 2

Views: 2957

Answers (1)

emoacht
emoacht

Reputation: 3556

I encountered exactly the same problem when I was reproducing Sending toast notifications from desktop apps sample. After a few hours for checking all the differences with the sample, I found that I had mistakenly added reference to "System.Runtime.InteropServices.dll" instead of "System.Runtime.InteropServices.WindowsRuntime.dll". Changing the reference to the latter, it worked fine.

Upvotes: 3

Related Questions