Assembly version number

  • Thread starter Thread starter Landley
  • Start date Start date
L

Landley

Hello All,

I am writing a windows service and wish to retrieve the version number of
the assembly. In a windows application, there is the Application class that
contains this information. Is there a similar method in windows services?

Landley
 
I am writing a windows service and wish to retrieve the version number of
the assembly. In a windows application, there is the Application class that
contains this information. Is there a similar method in windows services?

Assembly.GetName().Version. You can get the Assembly reference with
typeof(SomeClassInTheAssembly).Assembly or
Assembly.GetExecutingAssembly().



Mattias
 
Thanks.

Mattias Sjögren said:
services?

Assembly.GetName().Version. You can get the Assembly reference with
typeof(SomeClassInTheAssembly).Assembly or
Assembly.GetExecutingAssembly().



Mattias
 
You might want to define the version of your service in App.config
as a key/value pair like:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="version" value="1" />
</appSettings>
</configuration>

Then use System.Configuration.ConfigurationSetting.AppSettings property
to retrieve it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top