Comment obtenir le nom de l'application dans les applications de la fenêtre 8 et 8.1 d'une bibliothèque?

StackOverflow https://stackoverflow.com//questions/21002121

Question

J'ai 2 projets nommés "échantillon" (application de magasin) et "Samplelib" (Bibliothèque de magasins).Je voulais obtenir le nom de l'application en cours d'exécution lorsque je l'appelle de l'échantillon.csproj.

Je voulais obtenir un nom de l'application en fonction de la version de OS IT:

in 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();

in 8.1:

            Windows.ApplicationModel.Package.Current.DisplayName

Mais puis-je le faire de manière conditionnelle lorsque je fixe un cadre cible sur le projet LIB comme 8,0?

Était-ce utile?

La solution

Vous pouvez créer deux projets, un pour 8 et un pour 8.1, et définissez une constante de compilation personnalisée qui compilait de manière conditionnelle en fonction de ce que vous avez défini pour la valeur.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top