If you are talking about getting the current version of your service automatically from the assembly properties then you can set up a property such as below in your ServiceBase
class.
public static string ServiceVersion { get; private set; }
Then in your OnStart
method add the following...
ServiceVersion = typeof(Program).Assembly.GetName().Version.ToString();
Full Example
using System.Diagnostics;
using System.ServiceProcess;
public partial class VaultServerUtilities : ServiceBase
{
public static string ServiceVersion { get; private set; }
public VaultServerUtilities()
{
InitializeComponent();
VSUEventLog = new EventLog();
if (!EventLog.SourceExists("Vault Server Utilities"))
{
EventLog.CreateEventSource("Vault Server Utilities", "Service Log");
}
VSUEventLog.Source = "Vault Server Utilities";
VSUEventLog.Log = "Service Log";
}
protected override void OnStart(string[] args)
{
ServiceVersion = typeof(Program).Assembly.GetName().Version.ToString();
VSUEventLog.WriteEntry(string.Format("Vault Server Utilities v{0} has started successfully.", ServiceVersion));
}
protected override void OnStop()
{
VSUEventLog.WriteEntry(string.Format("Vault Server Utilities v{0} has be shutdown.", ServiceVersion));
}
}
In the example above my event log displays the current version of my service...
