Search code examples
c#asp.net-corevisual-studio-debuggingdnx

Cannot watch contents of variables when debuggin ASP.NET 5 IIS Express


When I debug an ASP.NET 5 web application it hits my breakpoints, but I cannot watch the contents of variables created locally.

Example code from startup.cs using empty project as template:

public void Configure(IApplicationBuilder app)
{
    app.UseIISPlatformHandler();
    var dummy = DateTime.Now;

    app.Run(async (context) =>
    {
        await context.Response.WriteAsync("Hello World! " + dummy);
    });
}

When I put a breakpoint on "app.Run(...." it hits the breakpoint but I cannot see the content of variable dummy. If I add dummy to Watch it says "error CS0103: The name 'dummy' does not exist in the current context". Although I can see the contents of DateTime.Now, which gives me the exact Date and Time every time I hover it. The same happens when I put a breakpoint in an MVC controller and watch variables overthere.

I was following a Pluralsight course and I also have this with the project I created while following that course, as well with the example files that come with the course.

During debug VS2015 is attached to the dnx.exe process In the video I see the VS2015 is attached to the IISExpress.exe process. But that course is from nov. 2015 perhaps something changed in the meanwhile.

Reboot of machine didn't help.

This is my first question over here, if more info is needed please let me know, and I'll do my best to provide.


Solution

  • I've found the answer. Sometimes a night of rest does miracles.

    I did a Google search on 'error CS0103: The name does not exist in the current context debug'. Without the word 'debug' you get a lot of results that don't help. I've found the following site: https://connect.microsoft.com/VisualStudio/feedback/details/1038150/visual-studio-2015-debugger-doesnt-recognize-a-variable

    The answer is: Menu > Debug > Options, "Use Managed Compatibility Mode". Checked that option and it worked for me. Also for the project I was working on.