Window service debug

P

Phil Hunt

I once created a Window app and later changed into a service. Now I can run
the app from the IDE just by clicking debug. And I can install and run it as
a service. Without any change whatsoever.

Now I created a service from the get go, but I cannot debug it from IDE,
does anyone know how or why ?

Thanks
 
J

Jeff Johnson

I once created a Window app and later changed into a service. Now I can run
the app from the IDE just by clicking debug. And I can install and run it
as a service. Without any change whatsoever.

I'd be interested to hear how you "changed" the app into a service.
Now I created a service from the get go, but I cannot debug it from IDE,
does anyone know how or why ?

Why is because it has always been this way. I think it's kind of cheesy, but
for some reason MS has never allowed the VS IDE to do whatever it needs to
do with the Service Control Manager to start and attach to a service with
one simple click.
 
P

phil hunt

Nothing really fancy, I just copy couple of lines from a real window service
on how it start the app. I don't have the thing in front of me now. But it
is somehting to to do with ServiceBase, or somehting like that.
 
J

J van Langen

?Hi,

What I do to develop windows services is creating 3 projects.

- Desktop application (develop/testing)
- Windows service
- SystemLogic (containing the functionality)

Create a desktop application that references the SystemLogic assembly and
construct the Main class you defined in the SystemLogic.
Do the same for the windows service.
I use for the SystemLogic a Start method and a Stop method.
From the windows service the start and stop method can be linked thru the
SystemLogic start and stop.
On the Desktop application I call the start in the FormConstructor and the
Stop in the FormClosed eventhandler.

In the SystemLogic assembly you'll program what your solution should do.

The major difference between the desktop application and the service is.

The try ... catch surrounding the SystemLogic start method will write a
EventLog record and the desktop application will display a messagebox.
I only use the desktop application for debugging/testing.

Note: If the service behaves different than the desktop version, you should
check the running user rights.

Jeroen,


"phil hunt" schreef in bericht
Nothing really fancy, I just copy couple of lines from a real window service
on how it start the app. I don't have the thing in front of me now. But it
is somehting to to do with ServiceBase, or somehting like that.
 
R

Registered User

A little more information is needed about this web service.
Why is because it has always been this way. I think it's kind of cheesy, but
for some reason MS has never allowed the VS IDE to do whatever it needs to
do with the Service Control Manager to start and attach to a service with
one simple click.
Using VS2008 I just created a WCF Service Library project and built
the project leaving the default template code unchanged. Hitting F5
brings up the WCF Test Client application. A breakpoint in the code
gets hit when the appropriate method is invoked.

regards
A.G.
 
J

Jeroen van Langen

?>>"Phil Hunt said:
A little more information is needed about this web service.
Using VS2008 I just created a WCF Service Library project and built
the project leaving the default template code unchanged. Hitting F5
brings up the WCF Test Client application. A breakpoint in the code
gets hit when the appropriate method is invoked.
regards
A.G.

I assume that it's not a Web service but a Windows service.

Jeroen
 
R

Registered User

I am not talking about WCF service. I am talking Windows Service
I made the incorrect assumption of a web service. Thank you for the
clarification.

regards
A.G.
 
P

Phil Hunt

Sorry guys. The service does not really run. I was mislead by the result.
Most of the work was done in the contructor, so when I create the service I
got the result I look for.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top