views:

463

answers:

4

I am using Visual Studio 2005.I am running my code in Debug mode only.But my break point is not being hit.

I followed :


  1. Cleared my solution and created the one again
  2. Closed the VS and Opened it again
  3. Restarted my PC and tested the break point

But i am unable to figure out the problem.

My Question is:


  1. Is it due to any virus ?
  2. Add-on feature in my IE 8.0 prevents this
  3. My VS is Corrupted ?
  4. I am having botn VS 2008 and VS 2005 installed in my machine so any version conflicts?

Suggestion is needed.

A: 

If you hover over the breakpoint in Visual Studio, does it indicate an error? Common problems are that the code hasn't been built, or the DLL that contains the code isn't loaded into the debugged process.

Andy
If i hand over the break point (design time,not at runtime)as expected, it shows the line number and file name,etc.
You should specifically do it at runtime to see if there are any symbols loading errors etc. All breakpoints show as valid until you actually attach to the process.
Pavel Minaev
+1  A: 

What kind of project is it (website, console app, ...) Are you running the project directly from visual studio, or attaching to it afterwards?

Usually when this happens to me, its because the assemblies that are being used to run the process I want to debug do not match the currently built assemblies from visual studio.

You mention IE8, so if this is a website, you should try to attach visual studio to the w3wp.exe process. Otherwise the breakpoint won't have any effect. Alternatively, run the website using visual studio.

Nader Shirazie
I am running intranet site.My OS is XP service Pack 2 and IIS 5.1.
VSS comes with buit in Web server.so again do i need to host it on IIS?
I believe the VSS webserver is really for dev only - I don't think its useful once you're deploying the website, so yes, you will need IIS. When you are trying to debug, what url are you using? Does it have a port in it -- for eg, is it http://localhost:5435/mysite?
Nader Shirazie
I did not deploy it yet. yes it has port in it.Now i am running it from IIS.http://localhost/FolderName/SomePage.aspx
When there is a (high) port, its usually because is using the Visual Studio WebServer (as if you click "Run" in studio). In that case, usually, the correct assemblies are being run, and breakpoints will be hit. However, sometimes the server will continue to run, even while Studio is not actually debugging. If there is no port (80 is the default), then it is usually because you are running through IIS. In that case, you need to specifically attach to the IIS process.Does this happen for all breakpoints? Or some specific breakpoint?
Nader Shirazie
+3  A: 

It sounds like the problem you are having may be due to the source code and the .pdb files being out of sync with each other.

Try these steps:

  1. Perform a "Clean" build in Visual Studio.
  2. Shut down Visual Studio.
  3. Delete any "bin" and "obj" folders in all of your project folders.
  4. Delete the solution .suo file

Sometimes the solution .suo file can become corrupt (doesn't cause Visual Studio to indicate any errors, but usually leads to strange behavior). Nine out of ten times, deleting the .suo file clears any strange behavior in Visual Studio.

The trick about deleting the "obj" folders forces Visual Studio to truely do a clean build the next time it compiles. Doing a "clean" build in Visual Studio only deletes the compiled binary results, it doesn't remove any intermediate object files that may have been created that Visual Studio might be linking against. By manually deleting the "obj" folders, you delete those cached object files and force a true rebuild.

Scott Dorman
OOps! Exactly your solution worked ! What a relief.Thanks man.
A: 

Though Scott Dorman has already provided the accurate answer, I would advise that you should understand how breakpoints are implemented in software and you'd be able to resolve such problems intuitively.

http://www.technochakra.com/software-breakpoints/ is one of my writeups that explains this in detail. Hope you'd find it useful. The last section of the article explains why debuggers don't allow to set breakpoints when binaries and source code are out of sync.

tc
Thank you ,i will do