Corrupt C# source file?

  • Thread starter Thread starter Ed Crowley
  • Start date Start date
E

Ed Crowley

I have a problem with one of the classes in my project; when I step through
the code the IDE appears to be stepping through lines that do not "exist"
such as blank lines and random lines within comment blocks!

I fixed the problem by pasting the code into Notepad, deleting the class and
recreating it.

Has anyone seen this happen before? Is it a symptom of something serious
going on?
 
Ed,

It's most likely an outdated .pdb (Program DataBase) file is being used.
First, remove all produced binaries and rebuild the whole solution. Second,
if you deploy the resultant assembly to GAC/web server/etc., be sure to
deploy the up-to-date PDB file as well.

The reason is that PDB contains mapping between the compiled IL and the
lines of source code that correspond to that IL. When the lines stored in
PDB do not match actual source code lines, you see strange things happening
like stepping into comment blocks.
 
I've had this happen to me frequently in the past. It happened when I would
check an assembly into sourcesafe that was once a part of my solution (not
anymore) and then someone would change it and I would end up with their
changed version. Debuggin, I would get "phantom" breakpoints and such. The
solution to the problem was simple: uncheck the read-only flag on the
assembly in question -- problem solved. Not sure why that happened or what
it really was. But unchecking the readonly flag solved it in those cases.
Perhaps not every case is this, but in our case it was.


Thanks,
Shawn



Dmitriy Lapshin said:
Ed,

It's most likely an outdated .pdb (Program DataBase) file is being used.
First, remove all produced binaries and rebuild the whole solution. Second,
if you deploy the resultant assembly to GAC/web server/etc., be sure to
deploy the up-to-date PDB file as well.

The reason is that PDB contains mapping between the compiled IL and the
lines of source code that correspond to that IL. When the lines stored in
PDB do not match actual source code lines, you see strange things happening
like stepping into comment blocks.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Ed Crowley said:
I have a problem with one of the classes in my project; when I step through
the code the IDE appears to be stepping through lines that do not "exist"
such as blank lines and random lines within comment blocks!

I fixed the problem by pasting the code into Notepad, deleting the class and
recreating it.

Has anyone seen this happen before? Is it a symptom of something serious
going on?
 
For what is it worth, you will also see a similar behavior if you edit your
code in the midst of debugging (stepping through) the code and then choose
to resume excution rather than restarting. In that case, all you need to do
is stop and restart your application.
--Ken
 
Back
Top