473,385 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Debug Windows Services

Hi,

How I Debug a Windows Services in VB 2005?

Thanks for all help.

Elioth
Aug 10 '06 #1
2 1944
Elioth,

You have a couple of options.

1) Start the service in the Service Control Manager and attach the VS
debugger to a running process via Debug | Processes. I don't like this
option because the application may have already performed a lot of work
before you can attach and set a breakpoint.

2) Setup the application to run either as a service or a console
application. It's much easier to debug a console application. The
following code demonstrates what I'm talking about. There are several
variations on this theme including the use of conditional compilation.

Shared Sub Main()

If Environment.UserInteractive Then

' Run as a console application.
Dim service As Service1 = New Service1
service.OnStart(Nothing)
Console.WriteLine("Press ENTER to quit...")
Console.ReadLine()
service.OnStop()

Else

' Assume the Service Control Manager invoked the application.
Dim ServicesToRun() As ServiceBase
ServicesToRun = New ServiceBase () {New Service1}
System.ServiceProcess.ServiceBase.Run(ServicesToRu n)

End If

End Sub

Brian
Elioth wrote:
Hi,

How I Debug a Windows Services in VB 2005?

Thanks for all help.

Elioth
Aug 11 '06 #2
A third option is to P/Invoke the DebugBreak method.

/claes

"Brian Gideon" <br*********@yahoo.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
Elioth,

You have a couple of options.

1) Start the service in the Service Control Manager and attach the VS
debugger to a running process via Debug | Processes. I don't like this
option because the application may have already performed a lot of work
before you can attach and set a breakpoint.

2) Setup the application to run either as a service or a console
application. It's much easier to debug a console application. The
following code demonstrates what I'm talking about. There are several
variations on this theme including the use of conditional compilation.

Shared Sub Main()

If Environment.UserInteractive Then

' Run as a console application.
Dim service As Service1 = New Service1
service.OnStart(Nothing)
Console.WriteLine("Press ENTER to quit...")
Console.ReadLine()
service.OnStop()

Else

' Assume the Service Control Manager invoked the application.
Dim ServicesToRun() As ServiceBase
ServicesToRun = New ServiceBase () {New Service1}
System.ServiceProcess.ServiceBase.Run(ServicesToRu n)

End If

End Sub

Brian
Elioth wrote:
>Hi,

How I Debug a Windows Services in VB 2005?

Thanks for all help.

Elioth

Aug 14 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Grant Schenck | last post by:
Hello, I'm trying to figure out how to debug a very simple COM object I developed in VB. I'm very new to VB and ASP so I have a lot to learn. That said, I found what I thought was perfect...
4
by: Stephen Miller | last post by:
Hi, I am running v1.1.4322 on Win2K server and unable to debug a ASP.Net application running locally, using a full URL (ie www.mysite.com). When I hit F5, I get the following error message: ...
1
by: Reza Sadeghi | last post by:
Hi I am getting this error when I tried to browse any asp.net in visual studio.net. I can build the project but when I try to run and debug the project I get error message that "Unable to start...
5
by: SiD` | last post by:
when starting a windows service writte in vb.net, a messagebox appears: cannot start service from the command line or a debugger. A windows service must first be installed using installutil.exe ...
4
by: Rob R. Ainscough | last post by:
I've created several DLL's that I use in other projects. I "Add Reference" to these other projects pointing to my DLL. Probelm is, I can't seem to be able to step into my DLL code (from these...
7
by: Sunil Varma | last post by:
Hello all, I wrote a Windows Service in VC.NET 2005 I want to debug the solution. I tried as mentioned in the following link. ...
46
by: Ian Boyd | last post by:
IIS5, on a Windows 2000 Server machine. Debeg.WriteLine "Hello, world!" How can i view it?
3
by: =?Utf-8?B?bG10dGFn?= | last post by:
We have developed a number of different applications (ASP.NET web site, Windows services, DLLs, Windows forms, etc.) in C# 2.0. We have developed and unit tested all these applications/components...
2
by: joelkeepup | last post by:
Hi, I made a change this morning and now im getting an error that says either "a is undefined or null" or "e is undefined or null" the microsoft ajax line is below, I have no idea how to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.