diff options
-rw-r--r-- | crypto/src/bcpg/ArmoredOutputStream.cs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/crypto/src/bcpg/ArmoredOutputStream.cs b/crypto/src/bcpg/ArmoredOutputStream.cs index 37dcf2340..03d4a1a91 100644 --- a/crypto/src/bcpg/ArmoredOutputStream.cs +++ b/crypto/src/bcpg/ArmoredOutputStream.cs @@ -133,9 +133,14 @@ namespace Org.BouncyCastle.Bcpg private static string CreateVersion() { var assembly = Assembly.GetExecutingAssembly(); - var title = assembly.GetCustomAttribute<AssemblyTitleAttribute>().Title; - var version = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion; - return title + " v" + version; + + var titleAttr = assembly.GetCustomAttribute<AssemblyTitleAttribute>(); + var versionAttr = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>(); + + if (titleAttr == null || versionAttr == null) + return "BouncyCastle (unknown version)"; + + return titleAttr.Title + " v" + versionAttr.InformationalVersion; } private static readonly string Version = CreateVersion(); |