mark007 Posted August 23, 2005 Posted August 23, 2005 I'm sure it must be doable by changing some of the settings in the project file for a console app as per creating a class library. Given class library changes are: OutputType="exe"==>OutputType="library" StartupObject = "Module1"==>StartupObject = "" I'm thinking that I probably just need to change the startup object to "" and create the standard ServiceBase and installer clases needed for a service. Any thoughts? I was also wondering whether there is any reason for a service to be an exe rather than dll? Thanks. :) Quote Please check the Knowledge Base before you post. "Computers are useless. They can only give you answers." - Pablo Picasso The Code Net
HJB417 Posted August 24, 2005 Posted August 24, 2005 services are executable that run under a different windows account. Quote
mark007 Posted August 24, 2005 Author Posted August 24, 2005 Thanks for the reply though I'm not sure how that helps me... I have created the code for my service - a cut down version being: Public Class ETUpdaterService Inherits System.ServiceProcess.ServiceBase Private WithEvents m_timer As New System.Timers.Timer Protected Overrides Sub OnStart(ByVal args() As String) 'this is where we start the checking for updates m_timer.Interval = 600000 'every 10 minutes m_timer.AutoReset = True m_timer.Enabled = True End Sub Protected Overrides Sub OnStop() 'stop the timer m_timer.Enabled = False End Sub Private Sub m_timer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) _ Handles m_timer.Elapsed m_timer.Enabled = False 'check to see if there are any updates m_timer.Enabled = True End Sub Protected Overrides Sub OnCustomCommand(ByVal command As Integer) m_timer.Enabled = False If command = 255 Then 'force the app to download new updates End If m_timer.Enabled = True End Sub End Class 'Now comes installation class <RunInstaller(True)> Public Class ServiceInstaller Inherits System.Configuration.Install.Installer #Region " Component Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Component Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Installer overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Component Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Component Designer 'It can be modified using the Component Designer. 'Do not modify it using the code editor. Friend WithEvents ServiceProcessInstaller1 As System.ServiceProcess.ServiceProcessInstaller Friend WithEvents ServiceInstaller1 As System.ServiceProcess.ServiceInstaller <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.ServiceProcessInstaller1 = New System.ServiceProcess.ServiceProcessInstaller Me.ServiceInstaller1 = New System.ServiceProcess.ServiceInstaller ' 'ServiceProcessInstaller1 ' Me.ServiceProcessInstaller1.Account = ServiceProcess.ServiceAccount.LocalSystem Me.ServiceProcessInstaller1.Password = Nothing Me.ServiceProcessInstaller1.Username = Nothing Me.ServiceInstaller1.DisplayName = "ETUpdaterService" Me.ServiceInstaller1.ServiceName = "ETUpdaterService" Me.ServiceInstaller1.StartType = ServiceProcess.ServiceStartMode.Manual ' 'ProjectInstaller ' Me.Installers.AddRange(New System.Configuration.Install.Installer() _ {Me.ServiceProcessInstaller1, Me.ServiceInstaller1}) End Sub #End Region End Class I created this in a windows console app for the time being. Clearly though there isn't a sub main. I would be intrigued to see the output of the vbproj file for a service to see how it is setup and if changing the relevant entries will fool vb.net standard into creating a windows service. So again any ideas as to how it could be done and why it needs to be an exe. For instance if I compile it as per a library would it still install as a service with installutil? Or perhaps if I compile as an exe (ie. console app) with no code in sub main it would install and run correctly? :) Quote Please check the Knowledge Base before you post. "Computers are useless. They can only give you answers." - Pablo Picasso The Code Net
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.