라이브러리에서 창 8 및 8.1 응용 프로그램에서 앱 이름을 얻는 방법은 무엇입니까?

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

문제

"샘플"(상점 앱) 및 "SAMPLELIB"(상점 라이브러리)라는 2 개의 프로젝트가 있습니다.샘플 .csproj에서 전화를 걸 때 실행중인 앱의 이름을 얻고 싶었습니다.

의 버전의 버전을 기반으로 앱 이름을 얻고 싶었습니다.

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
.

라이브 프로젝트에서 8.0으로 대상 프레임 워크를 설정할 때 조건부를 수행 할 수 있습니까?

도움이 되었습니까?

해결책

두 프로젝트를 8.1 동안 하나, 8.1의 경우 하나의 프로젝트를 만들고 값에 대해 설정 한 것에 따라 조건부로 컴파일 할 사용자 정의 컴파일러 상수를 정의 할 수 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top