Search code examples
desktop-bridge

CS0012 You must add a reference to assembly Windows, Version 255,255,255,255 WindowsRuntime


I am trying to follow the help on extending my winforms app with UWP

private async void button1_Click(object sender, EventArgs e)
    {
        string str = "WinTreeWUP://";

        Uri uri = new Uri(str);

        var success = await Windows.System.Launcher.LaunchUriAsync(uri);
    }

you must add a reference

I have already added the references suggested by the docs as this screen dump shows.

The UWP app targets minimum of Windows Version 1809 build 17763 I am using VS2017 V15.9.3

The full error is

CS0012  C# The type 'IAsyncAction' is defined in an assembly that is not referenced. You must add a reference to assembly 'Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime'.

The source is at https://github.com/kgreed/WinTree

I am using the following references in the winforms project

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Facades\System.Runtime.InteropServices.WindowsRuntime.dll
          C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Runtime.WindowsRuntime.dll
    C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Runtime.WindowsRuntime.UI.Xaml.dll

C:\Program Files (x86)\Windows Kits\10\References\10.0.17763.0\Windows.Foundation.FoundationContract\3.0.0.0\Windows.Foundation.FoundationContract.winmd

C:\Program Files (x86)\Windows Kits\10\References\10.0.17763.0\Windows.Foundation.UniversalApiContract\7.0.0.0\Windows.Foundation.UniversalApiContract.winmd

Solution

  • I added a reference to C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.17763.0\Windows.winmd

    the build is no longer complaining.