Why is Visual Studio dropping me into a disassembly window when debugging?
I am facing a strange problem while I am debugging my program.
I developed a program that was working fine. Even when I made a minor change (added a hard-coded statement instead of putting watch for a variable and changing its value) in one part of the code, it was still working fine. But then I removed those changes, and from that point onward the program has been behaving very oddly. The variable that was hard-coded is still keeping the hard-coded value and not the one it should have according to flow.
I changed the line number 24 with the statement
return "shweta@2k7.com";
and again reverted the change to make it similar to the previous one, except that I deleted one blank line. So the total number of lines in the current code is 1 fewer than the previous code as shown below.
Now when I debug it, the control goes up to line no 26 even though there is nothing written there, and it returns the previous value "shweta@2k7.com" (which occurs nowhere in the code), instead of " ".
Current Code:
1 public string GetUserEmail(string userName)
2 {
3
4 if (!UserExists(userName)) return "";
5 try
6 {
7 DirectorySearcher search = new DirectorySearcher(_directoryEntry);
8 search.Filter = "(SAMAccountName=" + userName + ")";
9 search.PropertiesToLoad.Add("mail");
. .
. .
. .
19 }
21 catch
22 {
23 return ""; //"username@domain.com";
24 }
25 }
Previous Code:
1 public string GetUserEmail(string userName)
2 {
3 if (!UserExists(userName)) return "";
4 try
5 {
6 DirectorySearcher search = new DirectorySearcher(_directoryEntry);
7 search.Filter = "(SAMAccountName=" + userName + ")";
8 search.PropertiesToLoad.Add("mail");
. .
. .
. .
18 }
22 catch
23 {
24 return "username@domain.com"; //line number 24
25 }
26 }
After returning from this function, control passes to the Disassembly window where some assembly code is displayed.
Why is this happening?
Yes you are correct, It is running older version.
I am using Visual studio 2008. I did all such things like cleaning solution prior to Build/rebuild. But no gain.
I know the line inside catch executes only if try block fails, but here scenario is different(confusing too). It is not looking whether try failed or succeed, it is just looking line numbers. because when there is nothing in the line 26, then also control goes there.
I tried by removing blank line at 26, then contr开发者_如何学运维ol went to line 27(26 after removing blank line). you'll wonder by knowing that there was comment at line 27!! However I have checkout the last safe version from SVN, and that worked fine.
But I'm also curious to know about this.
Shweta,
Line 24 is inside a catch
statement, which is executed only if the try()
fails. Is it possible that the try()
succeeds, so Line 24 never executes?
On second thought, this smells like a case of not running the code that you think you're running: is it possible that your new source hasn't compiled properly, so you're still running the old version? If you're using an IDE (or a good makefile), you might try running clean
, or manually deleting the object and executable files, and then rebuilding from scratch.
When you find the problem, please post a follow-up. I'm curious!
Good luck.
精彩评论