473,399 Members | 4,254 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,399 software developers and data experts.

Debugging a service with VS.NET

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
Jul 21 '05 #1
3 1827
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" <ne********@inaplex.com> a écrit dans le message de
news:ur**************@TK2MSFTNGP10.phx.gbl...
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

Jul 21 '05 #2
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:O4*************@tk2msftngp13.phx.gbl...
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" <ne********@inaplex.com> a écrit dans le message de
news:ur**************@TK2MSFTNGP10.phx.gbl...
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


Jul 21 '05 #3
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" <ne********@inaplex.com> wrote in message
news:ur**************@TK2MSFTNGP10.phx.gbl...
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

Jul 21 '05 #4

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

Similar topics

6
by: Dmitri Shvetsov | last post by:
Hi All, Did somebody see the situation when the VS refuses to debug the Web Service at all? I can't catch why, the initially created Web Service can be debugged very easy but after some changes...
0
by: ZMan | last post by:
Scenario: This is about debugging server side scripts that make calls to middle-tier business DLLs. The server side scripts are legacy ASP 3.0 pages, and the DLLs are managed DLLs...
16
by: Serdar Kalaycý | last post by:
Hi everybody, My problem seems a bit clichè but I could not work around. Well I read lots of MSDN papers and discussions, but my problem is a bit different from them. When I tried to run the...
3
by: David Evans | last post by:
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...
5
by: snicks | last post by:
I'm trying to exec a program external to my ASP.NET app using the following code. The external app is a VB.NET application. Dim sPPTOut As String sPPTOut = MDEPDirStr + sID + ".ppt" Dim p As...
3
by: Sathyaish | last post by:
How do you debug a web service in Visual Studio .NET 2003? To give you some background, I have been programming for some over 8 years now and know how to debug VB, VC++ apps in Visual Studio 6.0...
0
by: Ken Allen | last post by:
The MSDN documentation on remote debugging is a bit sparse, to say the least, and there is almost no information available on the 'best' way to configure this. I should note that my development...
4
by: John Wilmot | last post by:
I have a service that is set up to use remoting. Is there a way that calls from a web page to this service can be debugged in Visual Studio 2005?
7
by: GaryDean | last post by:
(this was also posted on the MSDN WCF forum but the answers over there are not so good) I have a WCF Library hosted by IIS 6 and it all works fine. However I need to step through the code in the...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.