Search code examples
c#dlluwpdispatcher

Error at importing dll file to an UWP project using c#


I'm working on UWP Project and, i want to add a reference it shows me a message error. I need that reference for using Dispatcher class and i dont find it on references path.

Any solutions ?

Message Error

Or if I install the dll file from NuGet Packages it throws me this warning:

Warning NU1701 Package 'WindowsBase 4.6.1055' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework 'UAP,Version=v10.0.17763'. This package may not be fully compatible with your project.


Solution

  • This is normal to have this error, since the reference you want to add is already integrated in UWP projects at the reference level you will find your dispatcher, you could use the code below to use dispatcher .

    await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
    () =>
    {
           // do some staff
    });