Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Dear Friends,

Greetings.

I am facing a trouble from last couple of weeks. I have created/coded a windows service using VB.NET in Microsoft visual studio 2010 which I am wanting to debug.

I searched many many solutions but could not get anything working with the service I have developed. I also tried to install the service and then attaching the process debugger to my mprogram. Once I am done I tried to add debug ponits, but not worth.

I would like to share more details as follows:

Here s the VB code for service

VB
Public Class pspldemows

    Private bln_LogFlag As Boolean

    Protected Overrides Sub OnStart(ByVal args() As String)

        tmr_mainws.Interval = 1000
        tmr_mainws.Enabled = True

    End Sub

    Protected Overrides Sub OnStop()

    End Sub

    Private Sub tmr_mainws_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmr_mainws.Tick

        tmr_mainws.Enabled = False
        Me.WriteNewLog()
        tmr_mainws.Enabled = True

    End Sub

    Private Sub WriteNewLog()

        Try
            If True = bln_LogFlag Then

                Me.evntlog_mainlog.WriteEntry("pspldemows is alive")
                bln_LogFlag = False

            ElseIf False = bln_LogFlag Then

                Me.evntlog_mainlog.WriteEntry("pspldemows is now willing to die")
                bln_LogFlag = True

            End If

        Catch ex As Exception
            Me.evntlog_mainlog.WriteEntry("pspldemows|WriteNewLog():<ERROR>: " & ex.Message)
        End Try

    End Sub

End Class


As generally required the project installer is also added to it and all the properties of serviceInstaller and serviceProcessInstaller.

To install the project I created a setup for this (as guided by following reference link to create setup), installed the program.

http://myhosting.com/blog/2010/09/creating-windows-service-visual-studio-2010/[^

When I have seen the services screen, I am able to see the service running, but not able to debug it.I am not getting where I am going wrong.

Guys, please help me out for this.

Your valuable suggestions and replies are appreciated in advance.

Thank you very much.

Regards,
G Nachiket
Posted
Updated 2-May-12 22:29pm
v2
Comments
Ravinder_Verma 3-May-12 3:28am    
Please provide more information and screen shot for ur issue.

1 solution

Make sure the service path is the same as your solution path (you installed the service from your bin\debug folder of your solution).

Attach the debugger to your service via Visual Studio.

If you need to debug the start of the service initializer, add a Thread.Sleep(10000) to your service start code so you have time to attach a debugger.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900