0

I have 4 web applications based on .net core. all of them call a business logic layer (class library)

i want my version to get updated on all 4 web applications.

I have tried to make a static class on my business logic layer. and on this class i have a property that gets the version as the following:

Assembly.GetEnteryAssembly().GetName().Version

i tried to call this static class from one of the applications, sadly it brings the version of the web application instead of the class library version.

I want a code that always brings me the version of class library regardless from where it is called.

2 Answers2

0

You can use Assembly.GetAssembly(typeof(YourClass)), being YourClass any class within desired assembly.

eduherminio
  • 1,514
  • 1
  • 15
  • 31
  • you gave me a guide at least i have used Assemply.GetExecutingAssembly() as the class where i get the version from is in the business logic, and GetEnteryAssembly always get the application version from where you have entered the application – Nadeem Tabbaa Jul 16 '19 at 10:46
  • [Have a look at this answer](https://stackoverflow.com/questions/27059748/which-is-better-for-getting-assembly-location-getassembly-location-or-getexe), in some scenarios you may not get what you're looking for using `GetExecutingAssembly()` – eduherminio Jul 16 '19 at 10:51
0

You can use typeof(Startup).Assembly.GetName().Version.ToString()

sisindrymedagam
  • 179
  • 2
  • 8