I have problem with debuging code. I try to resolve one bug, but when I set breakpoint in catch statement and add watch to see details I get message from Visual Studio like below. Why? Can anyone explain me why is happens?
Asked
Active
Viewed 117 times
0
-
Are you starting the application in the debugger, running in Debug mode? Also, you can usually use `$exception` to get the current exception. – Luaan Sep 22 '15 at 09:04
-
1I set in web.config DEBUG to true and turn off code optimalization – Jacek Sep 22 '15 at 09:05
-
4You may want to read [this question](http://stackoverflow.com/questions/730250/is-there-a-difference-between-throw-and-throw-ex) given your use of `throw exc`. If that's what you want, fair enough - just be aware of the difference... – James Thorpe Sep 22 '15 at 09:09
-
When you step one further? It may do the declaration actually when it is used. Are you sure you have the current code in the debugger? – Stefan Steinegger Sep 22 '15 at 09:11
-
Is your project a Web Application project or a Web Site project? – Matteo Umili Sep 22 '15 at 09:22
-
In the IDE, the compilation configuration is "Debug" or "Release"? – Matteo Umili Sep 22 '15 at 09:24
-
Did you add exc just now or did you add it for a different method before? – Thomas Weller Sep 22 '15 at 09:45
2 Answers
0
This error frequently occurs if you declare a variable in a loop or a try or if block and then attempt to access it from an enclosing code block or a separate code block.

BSG
- 2,084
- 14
- 19
-
Can you see such a code block in OP's question? If exc is not visible there, I don't know... – Thomas Weller Sep 22 '15 at 09:46