Skip to content

Commit a1bcc7a

Browse files
authored
Merge pull request #216 from EasyPost/assembly_fix
Fix Assembly information retrieval
2 parents 90bd85d + 15f58a9 commit a1bcc7a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

EasyPost/Client.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,15 @@ public Client(ClientConfiguration clientConfiguration)
4848
_restClient = new RestClient(clientConfiguration.ApiBase);
4949
_restClient.Timeout = ConnectTimeoutMilliseconds;
5050

51-
Assembly assembly = Assembly.GetExecutingAssembly();
52-
FileVersionInfo info = FileVersionInfo.GetVersionInfo(assembly.Location);
53-
_libraryVersion = info.FileVersion;
51+
try
52+
{
53+
// ref Example 1: https://docs.microsoft.com/en-us/dotnet/api/system.reflection.assemblyname.version?view=netframework-4.8#examples
54+
_libraryVersion = typeof(Client).Assembly.GetName().Version.ToString();
55+
} catch (Exception)
56+
{
57+
_libraryVersion = "Unknown";
58+
}
59+
5460

5561
string dotNetVersion = Environment.Version.ToString();
5662
if (dotNetVersion == "4.0.30319.42000")

0 commit comments

Comments
 (0)