2

I'm trying to install

  • Microsoft.Toolkit.Uwp.Notifications -Version 2.2.0

Nuget package for the following solution structure.

JSProj (universal App) - Targeting build 10586
    contains js App which has CSProj reference and can call C# method
    packages
        - Microsoft.Toolkit.Uwp.Notifications.JavaScript
        - Microsoft.NETCore.UniversalWindowsPlatform
CSProj (universal App) - Targeting build 10586
    contains C# methods that can be performed.
    packages
        - Microsoft.NETCore.UniversalWindowsPlatform

For the JS project, Microsoft.Toolkit.Uwp.Notifications fails to install by throwing error,

Could not install package 'Microsoft.NETCore.Jit 2.0.6'. You are trying to install this package into a project that targets 'UAP,Version=v10.0.10586', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.


But it works fine in CSProj, but throws a runtime IOException for the package, when I try to call the notification in C# method.

I tried downgrading package versions, and changing the Target build. But nothing seems to work.

Prajwal
  • 3,930
  • 5
  • 24
  • 50

1 Answers1

1

Anything you can reference from JS project must be a Windows Runtime Component. As the GitHub readme for UWP Community Toolkit states:

There's two notification projects...

  • Microsoft.Toolkit.Uwp.Notifications
  • Microsoft.Toolkit.Uwp.Notifications.JavaScript

The first project is where all the code is contained. The JavaScript project is just for packaging the WinMD to work for WinJS projects.

This means if you want to use the notifications you must either use the Microsoft.Toolkit.Uwp.Notifications.JavaScript package directly, or build a Windows Runtime Component using Microsoft.Toolkit.Uwp.Notifications and provide a WinRT safe class that you will use from JavaScript to access the functionality.

Martin Zikmund
  • 38,440
  • 7
  • 70
  • 91
  • my runtime component is there in `CSProj` which actually throws the `IOExeption`. I initially tried the second method you specified. Do I need `Microsoft.Toolkit.Uwp.Notifications` in `JSProj` for this? – Prajwal Mar 28 '18 at 09:29