Get assembly version in PCL

后端 未结 3 1127
悲哀的现实
悲哀的现实 2021-01-01 16:44

I have the following line of code in .NET 4.5 that I am trying to build as Portable Class Library. It\'s purpose is to get assembly version:

this.GetType().A         


        
3条回答
  •  时光说笑
    2021-01-01 17:33

        public static string Version
        {
            get
            {
                var assembly = typeof(MyType).GetTypeInfo().Assembly;
                // In some PCL profiles the above line is: var assembly = typeof(MyType).Assembly;
                var assemblyName = new AssemblyName(assembly.FullName);
                return assemblyName.Version.Major + "." + assemblyName.Version.Minor;
            }
        }
    

提交回复
热议问题