Programmatically Setting the Version of a Window's Service on the ProjectInstaller
I have a Windows Service created in Visual Studio 2005 in C#. I have a setup project and a ProjectInstaller class. I also have code to programmatically get the version from the AssemblyFileVersionAttribute.
I need to figure out where I set the version that I've obtained (and where this code should go). I tried placing it in the InitializeComponent method on ProjectInstaller.Designer.cs and then appending the version开发者_开发百科 to serviceInstaller1.DisplayName and serviceInstaller1.ServiceName. This didn't work and you're not supposed to modify the contents of this method.
Any ideas?
Rather than adding code to InitializeComponent
I'd just add it to the ProjectInstaller
's constructor, after the call to InitializeComponent
, I'm setting the ServiceProcessInstaller1.Username
etc there without problems, but I think you need to get hold of the other installer to set the username so it might work if you do something like:
((ServiceProcess.ServiceInstaller)ServiceProcessInstaller1.Parent.Installers[1]).DisplayName
精彩评论