Question

I have 2 projects named "Sample" (Store App), and "SampleLib" (Store Library). I wanted to get the name of the running app when I call it from Sample.csproj.

I wanted to get app name based on what version of OS it is:

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

But can I conditionally do it when I set target framework on Lib project as 8.0?

Was it helpful?

Solution

You can create two projects, one for 8 and one for 8.1, and define a custom compiler constant that will conditionally compile depending on what you set for the value.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top