Debugging windows service on Vista

I

ink

Hi all,

I cant seem to debug my windows service on my Vista machine.
It seems it has something to do with 0 Session.

What I would normally do is add the following code to my OnStart() but it
does not work on Vista


#if DEBUG
System.Diagnostics.Debugger.Break();
//System.Diagnostics.Debugger.Launch();
#endif

I found this article but I am not sure this is what I am looking for.
http://blogs.msdn.com/cjacks/archive/2006/12/12/debugging-a-service-on-windows-vista.aspx

I have tried it and it seems for be awfully low level.

Can any one help with this.

Thanks,
ink
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

What I do (no matter what OS) is that the OnStart does nothing more than
spawn a thread that is where all the work is performed.

In the thread you can use a Sleep to hold for a given time. This allows you
to attach your debug session to the process.
The waiting time is defined in the config file, so if it's 0 you wait
nothing and the process start as expected (this would be teh case when the
process is running alone).

OnStart()
{
new Thread( new ThreadStart( StartingPoint)).Start();
}
void StartingPoint()
{
if ( Configuration.AppSettings["StartDelayTime"] != "0" )
{
Thread.Sleep(
Convert.ToInt32(Configuration.AppSettings["StartDelayTime"] ));
}

.... code
}
 
I

ink

Hi

Thanks for getting back to me.

The process is always greyed out. i cant seem to attach to the running EXE.

Any other sugestions.

Thanks,
ink






Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

What I do (no matter what OS) is that the OnStart does nothing more than
spawn a thread that is where all the work is performed.

In the thread you can use a Sleep to hold for a given time. This allows
you to attach your debug session to the process.
The waiting time is defined in the config file, so if it's 0 you wait
nothing and the process start as expected (this would be teh case when the
process is running alone).

OnStart()
{
new Thread( new ThreadStart( StartingPoint)).Start();
}
void StartingPoint()
{
if ( Configuration.AppSettings["StartDelayTime"] != "0" )
{
Thread.Sleep(
Convert.ToInt32(Configuration.AppSettings["StartDelayTime"] ));
}

.... code
}

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
ink said:
Hi all,

I cant seem to debug my windows service on my Vista machine.
It seems it has something to do with 0 Session.

What I would normally do is add the following code to my OnStart() but it
does not work on Vista


#if DEBUG
System.Diagnostics.Debugger.Break();
//System.Diagnostics.Debugger.Launch();
#endif

I found this article but I am not sure this is what I am looking for.
http://blogs.msdn.com/cjacks/archive/2006/12/12/debugging-a-service-on-windows-vista.aspx

I have tried it and it seems for be awfully low level.

Can any one help with this.

Thanks,
ink
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Are you running your IDE as administrator?

I can attach to the processes without any problem.

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
ink said:
Hi

Thanks for getting back to me.

The process is always greyed out. i cant seem to attach to the running
EXE.

Any other sugestions.

Thanks,
ink






Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

What I do (no matter what OS) is that the OnStart does nothing more than
spawn a thread that is where all the work is performed.

In the thread you can use a Sleep to hold for a given time. This allows
you to attach your debug session to the process.
The waiting time is defined in the config file, so if it's 0 you wait
nothing and the process start as expected (this would be teh case when
the process is running alone).

OnStart()
{
new Thread( new ThreadStart( StartingPoint)).Start();
}
void StartingPoint()
{
if ( Configuration.AppSettings["StartDelayTime"] != "0" )
{
Thread.Sleep(
Convert.ToInt32(Configuration.AppSettings["StartDelayTime"] ));
}

.... code
}

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
ink said:
Hi all,

I cant seem to debug my windows service on my Vista machine.
It seems it has something to do with 0 Session.

What I would normally do is add the following code to my OnStart() but
it does not work on Vista


#if DEBUG
System.Diagnostics.Debugger.Break();
//System.Diagnostics.Debugger.Launch();
#endif

I found this article but I am not sure this is what I am looking for.
http://blogs.msdn.com/cjacks/archive/2006/12/12/debugging-a-service-on-windows-vista.aspx

I have tried it and it seems for be awfully low level.

Can any one help with this.

Thanks,
ink
 
I

ink

Hi,

I am running under my user name that is in the administrator group and i
have turned off the account control junk in Vista so it is defiantly running
as me.

The service is set to run under the local system account and i start it
manually


ink






Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

Are you running your IDE as administrator?

I can attach to the processes without any problem.

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
ink said:
Hi

Thanks for getting back to me.

The process is always greyed out. i cant seem to attach to the running
EXE.

Any other sugestions.

Thanks,
ink






Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

What I do (no matter what OS) is that the OnStart does nothing more than
spawn a thread that is where all the work is performed.

In the thread you can use a Sleep to hold for a given time. This allows
you to attach your debug session to the process.
The waiting time is defined in the config file, so if it's 0 you wait
nothing and the process start as expected (this would be teh case when
the process is running alone).

OnStart()
{
new Thread( new ThreadStart( StartingPoint)).Start();
}
void StartingPoint()
{
if ( Configuration.AppSettings["StartDelayTime"] != "0" )
{
Thread.Sleep(
Convert.ToInt32(Configuration.AppSettings["StartDelayTime"] ));
}

.... code
}

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
Hi all,

I cant seem to debug my windows service on my Vista machine.
It seems it has something to do with 0 Session.

What I would normally do is add the following code to my OnStart() but
it does not work on Vista


#if DEBUG
System.Diagnostics.Debugger.Break();
//System.Diagnostics.Debugger.Launch();
#endif

I found this article but I am not sure this is what I am looking for.
http://blogs.msdn.com/cjacks/archive/2006/12/12/debugging-a-service-on-windows-vista.aspx

I have tried it and it seems for be awfully low level.

Can any one help with this.

Thanks,
ink
 
I

ink

I didnt have all users ticked.

Now i see it.


Thanks

ink






ink said:
Hi,

I am running under my user name that is in the administrator group and i
have turned off the account control junk in Vista so it is defiantly
running as me.

The service is set to run under the local system account and i start it
manually


ink






Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

Are you running your IDE as administrator?

I can attach to the processes without any problem.

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
ink said:
Hi

Thanks for getting back to me.

The process is always greyed out. i cant seem to attach to the running
EXE.

Any other sugestions.

Thanks,
ink






"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.com> wrote
in message Hi,

What I do (no matter what OS) is that the OnStart does nothing more
than spawn a thread that is where all the work is performed.

In the thread you can use a Sleep to hold for a given time. This allows
you to attach your debug session to the process.
The waiting time is defined in the config file, so if it's 0 you wait
nothing and the process start as expected (this would be teh case when
the process is running alone).

OnStart()
{
new Thread( new ThreadStart( StartingPoint)).Start();
}
void StartingPoint()
{
if ( Configuration.AppSettings["StartDelayTime"] != "0" )
{
Thread.Sleep(
Convert.ToInt32(Configuration.AppSettings["StartDelayTime"] ));
}

.... code
}

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
Hi all,

I cant seem to debug my windows service on my Vista machine.
It seems it has something to do with 0 Session.

What I would normally do is add the following code to my OnStart() but
it does not work on Vista


#if DEBUG
System.Diagnostics.Debugger.Break();
//System.Diagnostics.Debugger.Launch();
#endif

I found this article but I am not sure this is what I am looking for.
http://blogs.msdn.com/cjacks/archive/2006/12/12/debugging-a-service-on-windows-vista.aspx

I have tried it and it seems for be awfully low level.

Can any one help with this.

Thanks,
ink
 

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