2016-06-13 8 views
0

WPFデスクトップアプリケーション(Windows 10)からユニバーサルWindowsアプリケーションを起動する必要があります(実際には、ユニバーサルWindowsアプリケーションサービスを呼び出す必要がありますが、現在、アプリケーションを起動するだけの問題)。WPFからユニバーサルWindowsアプリケーションを起動

ほとんどの場合、私はここの例に従うことを試みています:Launch a Universal App from a WPF App

問題なくUniversalTargetAppを作成するためのコードに従うことができます。しかし、.csprojファイルへの参照を追加して「Windows 10の機能を照らす」ようにしようとすると、エラーが発生します。

<!-- 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 --> 

しかし、私が行うとき、私はエラーを取得する:

彼はItemGroup参照にこれを追加すると言う

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. 

明らかにユニバーサルのWindowsアセンブリへの参照を追加する彼の方法を働きましたWindows 10の彼のバージョンでは、彼は彼の例を掲載していないだろう。しかし、これは、Universal Windowsアセンブリへの参照を追加する正しい方法ではないこと、または壊れていないことも明らかです。

私は、ユニバーサルWindowsアセンブリを正しく参照する方法を追いかけようとしています。私が見つけたすべてはこれです:

How to call WinRT APIs in Windows 8 from C# Desktop Applications

しかし、それは、Windows 8にさかのぼり、と私はそれは、Windows 10で

を動作させることができていませんでしたことは誰も私に適切な方法を教えてもらえますユニバーサルWindowsアセンブリを参照するために、Windows.System.Launcher.LaunchUriAsync()を呼び出し、Windows.ApplicationModel.AppService.AppServiceConnectionsなどを作成します。

は--- Mehrzad Chehrazの提案を1として---

を編集、私は最後を残して、最初の2つの参照を削除しました。それで、私はもはや複数の参照エラーを取得していません。しかし、私はまだ編集していません。

次のコード:

var options = new LauncherOptions { TargetApplicationPackageFamilyName = TargetPackageFamilyName }; 
bool success = await Launcher.LaunchUriAsync(uri, options); 

がエラーを生成します

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'?) 

任意のアイデア?

答えて

0

、最初の二つの基準ノードを削除するだけで、最後の1を維持:

<!-- Light up Windows 10 features --> 
<Reference Include="Windows"> 
    <HintPath>C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd</HintPath> 
</Reference> 
<!-- Light up Windows 10 features --> 

Launcher.LaunchUriAsyncこのように動作しますが、AppServiceConnectionをテストしていませんでした。

0

私はここで答えの一部が見つかりました:

Load UWP library into .NET Framework app

ステップ1:に入れます。csprojファイル

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

ステップ2:

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

ステップ3への参照を追加します。

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll 
への参照を追加します。
関連する問題