質問

「サンプル」(Store App)と「SampleLib」(Store Library)という2つのプロジェクトがあります。sample.csprojからそれを呼び出すとき、私は実行中のアプリの名前を取得したいと思いました。

OSのバージョンに基づいてアプリ名を取得したいのです:

8.0:

            // Get the assembly with Reflection:
            Assembly assembly = typeof(App).GetTypeInfo().Assembly;

            // Get the custom attribute informations:
            var titleAttribute = assembly.CustomAttributes.Where(ca => ca.AttributeType == typeof(AssemblyTitleAttribute)).FirstOrDefault();

            // Now get the string value contained in the constructor:
            return titleAttribute.ConstructorArguments[0].Value.ToString();
.

8.1:

            Windows.ApplicationModel.Package.Current.DisplayName
.

しかし、LIBプロジェクトでターゲットフレームワークを8.0として設定したときに条件付きでそれを行うことができますか?

役に立ちましたか?

解決

8つのプロジェクトを作成することができ、1つは8.1用に1つ、および値に設定した内容に応じてコンディショニングコンパイラ定数を定義できます。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top