PC Review


Reply
Thread Tools Rate Thread

Debugging a service with VS.NET

 
 
David Evans
Guest
Posts: n/a
 
      29th Dec 2003
Hi

I have a service created in VS.NET, which I can install and run quite
happily. After teh service is running, I can attach and run the debugger.

However, if I set a breakpoint in the IDE the break point is (presumably)
hit, but after a long pause there is an error that says "Source code cannot
be found"

I have tried:
putting the .pdb file into the install direcory and Windows\System32
installing into the default bin\Debug directory that VS.NET builds in

Any help appreciated - debugging using trace is no fun...

Regards

David


 
Reply With Quote
 
 
 
 
José Joye
Guest
Posts: n/a
 
      30th Dec 2003
When I create a service, what I normally do is to set the default directory
where the main assembly is located.
Right at the beginning of OnStart(), I add the following:

Process pc = Process.GetCurrentProcess();
Directory.SetCurrentDirectory
(pc.MainModule.FileName.Substring(0,pc.MainModule.FileName.LastIndexOf(@"\")
));

By the way, if I remember correctly, the default directory for a Service is
the \System32 dir. Since you tried to place the PDB(s) in the \System32, I'm
not sure it will solve your particular problem.

Grive a try ;-)

José

"David Evans" <(E-Mail Removed)> a écrit dans le message de
news:(E-Mail Removed)...
> Hi
>
> I have a service created in VS.NET, which I can install and run quite
> happily. After teh service is running, I can attach and run the debugger.
>
> However, if I set a breakpoint in the IDE the break point is (presumably)
> hit, but after a long pause there is an error that says "Source code

cannot
> be found"
>
> I have tried:
> putting the .pdb file into the install direcory and Windows\System32
> installing into the default bin\Debug directory that VS.NET builds in
>
> Any help appreciated - debugging using trace is no fun...
>
> Regards
>
> David
>
>



 
Reply With Quote
 
David Evans
Guest
Posts: n/a
 
      30th Dec 2003
Jose

Thank you very much. I suspected that it was an issue like this, which is
why I copied the .pdb file to System32.

That didn't work, and your approach did.

Regards

David


"José Joye" <jose.joye@__No_SPam__bluewin__maPS_oN__.ch> wrote in message
news:(E-Mail Removed)...
> When I create a service, what I normally do is to set the default

directory
> where the main assembly is located.
> Right at the beginning of OnStart(), I add the following:
>
> Process pc = Process.GetCurrentProcess();
> Directory.SetCurrentDirectory
>

(pc.MainModule.FileName.Substring(0,pc.MainModule.FileName.LastIndexOf(@"\")
> ));
>
> By the way, if I remember correctly, the default directory for a Service

is
> the \System32 dir. Since you tried to place the PDB(s) in the \System32,

I'm
> not sure it will solve your particular problem.
>
> Grive a try ;-)
>
> José
>
> "David Evans" <(E-Mail Removed)> a écrit dans le message de
> news:(E-Mail Removed)...
> > Hi
> >
> > I have a service created in VS.NET, which I can install and run quite
> > happily. After teh service is running, I can attach and run the

debugger.
> >
> > However, if I set a breakpoint in the IDE the break point is

(presumably)
> > hit, but after a long pause there is an error that says "Source code

> cannot
> > be found"
> >
> > I have tried:
> > putting the .pdb file into the install direcory and Windows\System32
> > installing into the default bin\Debug directory that VS.NET builds in
> >
> > Any help appreciated - debugging using trace is no fun...
> >
> > Regards
> >
> > David
> >
> >

>
>



 
Reply With Quote
 
Carlos Kirkconnell
Guest
Posts: n/a
 
      30th Dec 2003
Creating classes that simulate services is a much better approach for
debugging services. Tracing the processes is really time consuming while
making impossible to debug the Start and Stop Methods. Personally what I do
when debugging a service is to create a class (not dericed from ServiceBase)
that has the Start an Stop methods. This class implement the same logic as
the service. Finally I use a form with buttons to test the "service
emulation". Debugging in this way seems easier to me.

"David Evans" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi
>
> I have a service created in VS.NET, which I can install and run quite
> happily. After teh service is running, I can attach and run the debugger.
>
> However, if I set a breakpoint in the IDE the break point is (presumably)
> hit, but after a long pause there is an error that says "Source code

cannot
> be found"
>
> I have tried:
> putting the .pdb file into the install direcory and Windows\System32
> installing into the default bin\Debug directory that VS.NET builds in
>
> Any help appreciated - debugging using trace is no fun...
>
> Regards
>
> David
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
debugging a web service =?Utf-8?B?SnVsaWE=?= Microsoft ASP .NET 1 19th May 2006 01:39 PM
Debugging a Web Service Sathyaish Microsoft C# .NET 3 4th Feb 2006 08:23 PM
Debugging a web service Nick Microsoft ASP .NET 2 14th Sep 2005 04:04 PM
JIT Debugging and EXE to Service =?Utf-8?B?VG9t?= Microsoft Dot NET Framework Forms 1 14th May 2004 07:41 PM
Web Service debugging ? Dmitri Shvetsov Microsoft C# .NET 6 19th Jul 2003 08:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:49 PM.