I need to launch a Universal Windows app from a WPF desktop application, in Windows 10. (Actually, I need to make calls against a Universal Windows App Service, but currently, I'm having problems just getting the app launched.)
Mostly, I'm trying to follow the example here: Launch a Universal App from a WPF App.
I'm able to follow the code to create his UniversalTargetApp without problems. But when I try to "Light up Windows 10 features" by adding his references to the .csproj file, I get errors.
He says to add this to the references ItemGroup:
<!-- Light up Windows 10 features -->
<Reference Include="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Runtime.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.WindowsRuntime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Runtime.WindowsRuntime.dll</HintPath>
</Reference>
<Reference Include="Windows">
<HintPath>C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd</HintPath>
</Reference>
<!-- Light up Windows 10 features -->
But when I do, I get an error:
Multiple assemblies with equivalent identity have been imported: 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Runtime.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\Facades\System.Runtime.dll'. Remove one of the duplicate references.
Clearly his method of adding references to the Universal Windows assemblies worked for his version of Windows 10, or he'd not have posted his example. But also clearly, this isn't the correct method for adding references to the Universal Windows assemblies, or it'd not have broken.
I've been trying to chase down how to properly reference the Universal Windows assemblies. All I've found is this:
How to call WinRT APIs in Windows 8 from C# Desktop Applications
But that dates to Windows 8, and I've not been able to make it work in Windows 10.
Can anyone tell me the proper method for referencing the Universal Windows assemblies, so that I can call Windows.System.Launcher.LaunchUriAsync(), create Windows.ApplicationModel.AppService.AppServiceConnections, etc.?
---Edited---
As per Mehrzad Chehraz's suggestion, I removed the first two references, leaving only the last. With that, I'm no longer getting the multiple reference error. But I am still not compiling.
The following code:
var options = new LauncherOptions { TargetApplicationPackageFamilyName = TargetPackageFamilyName };
bool success = await Launcher.LaunchUriAsync(uri, options);
Generates an error:
Error CS4036
'IAsyncOperation<LaunchQuerySupportStatus>' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accepting a first argument of type 'IAsyncOperation<LaunchQuerySupportStatus>' could be found
(are you missing a using directive for 'System'?)
Any ideas?