开发者

Can't see params while stepping through .NET 4.0 source in C#/VS2010

As I step into .NET source (.NET source stepping is enabled in Debugging Options and Just my Code is disabled)开发者_JAVA技巧, for some reason in the Autos and Watch windows in VS2010, I can't view parameters in .NET framework functions in the watch or autos panes. I can see local variables however. Why is this?

Update: This is a debug 64-bit (x64) build with no optimizations. There is no error, I just can't "watch" parameters in functions like:

// Enumerable.cs

public class Lookup<TKey, TElement> : IEnumerable<IGrouping<TKey, TElement>>, ILookup<TKey, TElement>{
...
    internal static Lookup<TKey, TElement> Create<TSource>(IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer) {

Update 2: It seems that by default, only the release build of the .NET 4.0 framework is installed. You can still step into it, but you may not see some function parameters and local variables (and set breakpoints on some lines). What I guess I would really like is to use a Debug build of the .NET 4.0 framework so that I can see all params, locals and put breakpoints on all lines. How do I go about installing this, if I have VS2010 Premium already installed?


You probably need to disable optimizations.

Edit by Michael Goldshteyn - the question's author:

Here are the full instructions from that URL:

  1. The following environment variable must be set before VS2010 is started:

    set COMPLUS_ZapDisable=1

  2. The VS hosting process must be disabled:

    To disable the hosting process in VS2010

    1.Open a project in Visual Studio.
    2.On the Project menu, click Properties.
    3.Click the Debug tab.
    4.Clear the Enable the Visual Studio hosting process check box.


You may be debugging a release build - check that you are running a debug build. (what you can 'watch' seems to be rather variable in release builds)


Do you need to unset COMPLUS if you want to re-enable optimised debugging. Is this advised? Do you reset as follows

set COMPLUS_ZapDisable=0


From http://reflectorblog.red-gate.com/2012/03/debugging-debugging-experience/

Create a file in your executable folder named YourAppName.ini, where YourAppName is replaced with the name of your assembly's filename. So if you have SampleApp.exe, you will create SampleApp.ini.

The contents of this ini file should contain

[.NET Framework Debugging Control]
GenerateTrackingInfo=1
AllowOptimize=0

Save the file and start debugging. You may not need to disable the VS Studio Hosting process when doing this. Disabling the hosting process, as others have suggested, causes intermittent crashes when using the Immediate Window, which is an integral part of the debugging experience.

Happy debugging!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜