The docs show that AssemblyName.Version
is nullable. So this could be null:
Assembly.GetExecutingAssembly().GetName().Version
Under what conditions could Version
be null? The docs do not say.
Based on the comment by @EtiennedeMartel and an answer from the repo:
var an = new System.Reflection.AssemblyName("MyAssembly");
Console.WriteLine(an.Version is null); // true
So I don't expect it to be null for the cases above, but it could be null for an Assembly
created dynamically (i.e. at runtime).