0

I get NullReferenceException when trying to get version from assemblyinfo in UWP app. Below is the code that I am using :

    return typeof(AssemblyInfo).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyVersionAttribute>().Version;
shagufta syed
  • 441
  • 6
  • 23
  • Possible duplicate of [What is a NullReferenceException, and how do I fix it?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Romasz Jun 10 '16 at 06:47

1 Answers1

1

You can get version without using reflection, with code like:

   PackageVersion pv= Package.Current.Id.Version;
   string version= $"{pv.Major}.{pv.Minor}.{pv.Build}.{pv.Revision}";
Alexej Sommer
  • 2,677
  • 1
  • 14
  • 25