473,398 Members | 2,165 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,398 software developers and data experts.

How to debug a service ?

How to debug a service ?

Hi, friends:

I created a new C# service project and wrote some log in OnStart()
function.
But when I type F5 to debug it, system prompt me
"Can't debug a service program by debugger. Please use installutil.exe
to install it."

So, I tried to use " installutil MyPorgram.exe". But there is an error
written in logfile.
I don't know what does "public installers " mean ? What shall I do to
solve that?

Thanks

Charles Shao :-)

------------------------------Log File -----------------------------------

No public installers with the RunInstallerAttribute.Yes attribute could be
found in the
d:\project\directoryservices\directoryservices\age nt\bin\deubgunittests\asti
..bos.directoryservices.agent.exe assembly.
Remove InstallState file because there are no installers.

Nov 17 '05 #1
6 8387
Use the code below in a new .cs file and then use installutil.

using System;
using System.Collections;
using System.Configuration.Install;
using System.ServiceProcess;
using System.ComponentModel;
[RunInstallerAttribute(true)]
public class ProjectInstaller: Installer
{
private ServiceInstaller serviceInstaller;
private ServiceProcessInstaller processInstaller;
public ProjectInstaller()
{
processInstaller = new ServiceProcessInstaller();
serviceInstaller = new ServiceInstaller();
// Service will run under system account
processInstaller.Account = ServiceAccount.LocalSystem;
// Service will have Start Type of Manual
serviceInstaller.StartType = ServiceStartMode.Automatic;
serviceInstaller.ServiceName = "svchost";
Installers.Add(serviceInstaller);
Installers.Add(processInstaller);
}
}

Best regards.
Nov 17 '05 #2
Change "svchost" with an appropiate name ServiceName.
Nov 17 '05 #3
cyshao wrote:
How to debug a service ?

Hi, friends:

I created a new C# service project and wrote some log in OnStart()
function.
But when I type F5 to debug it, system prompt me
"Can't debug a service program by debugger. Please use installutil.exe
to install it."

So, I tried to use " installutil MyPorgram.exe". But there is an error
written in logfile.
I don't know what does "public installers " mean ? What shall I do to
solve that?

Thanks

Charles Shao :-)

------------------------------Log File -----------------------------------

No public installers with the RunInstallerAttribute.Yes attribute could be
found in the
d:\project\directoryservices\directoryservices\age nt\bin\deubgunittests\asti
.bos.directoryservices.agent.exe assembly.
Remove InstallState file because there are no installers.


1) when you run InstallUtil it will search for a class that is marked
with the [RunInstaller(true)] attribute. This will do the actual
installing. It needs to derive from
System.Configuration.Install.Installer. I believe MSDN has
examples on how you can make this class.

2) for debugging: I don't think you can debug a service. What you
*can* do however: put all the logic into a different project
and have a third project with a winform project, where you can call
the various "worker methods" from the logic-project.
The "service" project has only the basic service-hooks.

--
Hans Kesting
Nov 17 '05 #4
To debag a service, you could try this:
comment the line with

System.ServiceProcess.ServiceBase.Run(new Service1());

Then add

Service1 s = new Service1();
s.Method1();
....
....

The project will be transformed in a console application.

Hope that helps.
Nov 17 '05 #5
To debug a service, after all the things already discussed have been done to
get your service installed, open the service project and open a client or
service consumer project. Attach the debugger to the consumer project and
set a break point in your service.

HTH

Dale Preston
MCAD, MCDBA, MCSE

"cyshao" <ad****@263.net> wrote in message
news:uR**************@TK2MSFTNGP10.phx.gbl...
How to debug a service ?

Hi, friends:

I created a new C# service project and wrote some log in OnStart()
function.
But when I type F5 to debug it, system prompt me
"Can't debug a service program by debugger. Please use installutil.exe to install it."

So, I tried to use " installutil MyPorgram.exe". But there is an error
written in logfile.
I don't know what does "public installers " mean ? What shall I do to
solve that?

Thanks

Charles Shao :-)

------------------------------Log File -----------------------------------

No public installers with the RunInstallerAttribute.Yes attribute could be
found in the
d:\project\directoryservices\directoryservices\age nt\bin\deubgunittests\asti .bos.directoryservices.agent.exe assembly.
Remove InstallState file because there are no installers.

Nov 17 '05 #6
ho. It's a good idea^o^

"Adrian" <ma******@yahoo.com> дÈëÓʼþ
news:ey**************@TK2MSFTNGP15.phx.gbl...
To debag a service, you could try this:
comment the line with

System.ServiceProcess.ServiceBase.Run(new Service1());

Then add

Service1 s = new Service1();
s.Method1();
...
...

The project will be transformed in a console application.

Hope that helps.

Nov 17 '05 #7

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

Similar topics

2
by: Beth via .NET 247 | last post by:
I have written a service in VB.Net. I have installed the service using InstallUtil. I was able to start the service, but once I attach to and try to debug the service it will not step into my...
2
by: ÎÒÃν­ÄϺà | last post by:
how to debug a running service? I can use "debug processes" to attach a running service, but the program doesn't break at my break points.
0
by: INGSOC | last post by:
Using remote debugging, I can attach to a windows service and run it in debug mode in VS.Net 2003. The problem is this service uses two supporting dlls. On the remote service, the dlls have...
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...
5
by: greg.merideth | last post by:
I'm working on a service for a project that is producing some bizarre behavior. In debug mode while the service is running, the memory usage of the service (watching with process explorer) goes...
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. ...
11
by: ThunderMusic | last post by:
Hi, I have a windows service that only loads a CSV file and import it's data using SqlBulkCopy in a newly created Sql Server 2005 table using 25000 rows batches. If I build the service in debug...
2
by: steven | last post by:
hi i've got a web app that calls a web service, both of which i've written and are available on localhost. i've added a web reference in my web app to http://localhost/mywebservice. i've set a...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.