Load UWP library into .NET Framework app

后端 未结 2 810
醉话见心
醉话见心 2020-12-06 06:39

There are a number of articles(codeproject, blog1, blog2, forum) to use WinRT library into .Net Framework console application in Windows 8.

I tried it with UWP in Wi

相关标签:
2条回答
  • 2020-12-06 07:23

    Here are the steps working over here, note the subtle differences between yours:

    Step 1: Add to .csproj file

      <PropertyGroup>
        <TargetPlatformVersion>10.0</TargetPlatformVersion>
      </PropertyGroup>
    

    Step 2: Add reference to

    C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd
    

    Step 3: Add reference to

    C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll
    

    Note the differences, v4.5 instead of v4.5.1, and no references to System.Runtime.InteropServices.WindowsRuntime.dll.

    This works fine here (Win10, VS2015).

    Side note, call to Geolocator will fail regardless:

    This operation is only valid in the context of an app container. (Exception from HRESULT: 0x8007109A)
    

    It won't be available from within desktop, only types referenced here are supported in desktop.

    0 讨论(0)
  • 2020-12-06 07:25

    I had this error and I upgraded the version of Microsoft.NETCore.UniversalWindowsPlatform from "5.0.0" to "5.2.2" and my program started working

    0 讨论(0)
提交回复
热议问题