Run as Application or Service

Microsoft Visual studio pro 2008 (full p...
May 28, 2010 at 07:50:28
Specs: Windows 7
Hi, I've been trying to create an application in
VB.NET that could run
either as a common application (offering a user
interface and all) or
as a Service.
I don't know if I'm in the right path or what, I've
been investigating and
got to this part (Service1.Designer):

Imports System.ServiceProcess
Imports System.IO

)> _
Partial Class Service1

'UserService overrides dispose to clean up
the component list.

)> _
Protected Overrides Sub Dispose(ByVal
disposing As Boolean)
If disposing AndAlso components
IsNot Nothing Then
End If
End Try
End Sub

' The main entry point for the process
<MTAThread()> _

)> _
Shared Sub Main()

Dim flines As String() =
If flines.Length > 0 Then
If flines(0) = "form" Then
Dim form1 As Form1 = New Form1
Dim ServicesToRun() As

' More than one NT Service may run
within the same
process. To add
' another service to this process,
change the following line
' create a second service object.
For example,
' ServicesToRun = New
System.ServiceProcess.ServiceBase () {New
Service1, New
ServicesToRun = New
System.ServiceProcess.ServiceBase() {New

End If
MsgBox("No config file")
End If

End Sub

'Required by the Component Designer
Private components As

' NOTE: The following procedure is required
by the Component
' It can be modified using the Component
' Do not modify it using the code editor.

> _
Private Sub InitializeComponent()
Me.ServiceName = "Service1"

End Sub

End Class

To get to this part, I've created a windows
service project, added a
form Form1 witch would be the one called if
the initializacion
demanded that it should run as an application,
and a file that would
let me choose whether I want to start as an
application or a service.
The thing is that starting as a service,
everything runs well, but when
it has to start as an application, it just shows
the form for about half
a second and then ends completely.

What am I doing wrong? Should I start with a
different approach and
in this case, which?
Any help would be really appreciated, thanks
in advance.


See More: Run as Application or Service

Report •

June 1, 2010 at 02:15:29
You can try Application as Service by Eltima Software. Eltima offers 14 days free trial version.

Report •

June 1, 2010 at 06:09:00
But I neet to develop the application to be stand alone, not using
a third party tool to make it run as an service.
I read a post here that explained how to do it for C#, tried to
reproduce it, and the application, when starting as common
application and not a service, would finnish immediately.

Report •

October 26, 2010 at 11:59:03
We started out moding our code to be a service but there were problems on Server 2008 that we didn't anticipate. Ended up going with AlwaysUp

Report •

Related Solutions

Ask Question