VS 2010 does not seem to reliably step into evaled code. I have a debugger statement in the evaled code. In my example the evaled code is attached to a button click of the page.
If I attach to IE8 after opening the page in question and click the button, VS opens a window titled "Find Source: eval code". Looking at the Solution Explorer, there are no nodes for "Eval Code".
If I attach to IE8 before opening the page in question, VS seems to have a "consolidated" view of all the evaled code. When clicking the button, VS hits the breakpoint. However the symbols/line numbers seem to be out of sync as it stops on the wrong line.
Both cases work great in VS 2008 running on the same machine. I am attaching to the IE8 instance from Tools->Attach to Process from within VS.
Contrived Example:
<html>
<body>
<input id="name" />
<button id="sayHello">Say Hello</button>
<script type="text/javascript">
//assume the string below is loaded from a file through an xhr request
eval("function hello(name) {\r\n\tdebugger;\r\n\talert('hello ' + name);\r\n}");
document.getElementById("sayHello")
.attachEvent("onclick",
function() {
hello(document.getElementById("name").value);
});
</script>
</body>
</html>
Explination: We use the Dojo Toolkit client side library in our applications. Dojo uses some JavaScript to load in file dependencies dynamically by downloading and then evaling the JavaScript into your current scope. For production you create a "build" that makes a consolidated and minified version of all your dependencies. This makes writing and including code very easy as you have smaller files.
http://docs.dojocampus.org/build/index
As this seems to be a VS 2010 issue, I have opened a Microsoft Connect ticket. Please vote it up or mark it as reproduceable if you have the same issue.