Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Breakpoint put in decompiled assembly from .Net Reflector is never hit while debugging in Visual Studio

First, I created a testing assembly HelloWorld.dll which I want to debug and built it with release configuration.

namespace HelloWorld
{
    public class HelloClass
    {
        public string SayHello(string name)
        {
            return "Hi " + name + "!";
        }
    }
}

Then I created standart ASP.NET MVC project and:

  • Referenced HelloWorld.dll assembly
  • Modified HomeController's About method

    public ActionResult About()
    {
        var testingClass = new HelloClass();
        ViewBag.Message = testingClass.SayHello("John");
        return View();
    }
    
  • Via .NET Reflector Object Browser decompiled HelloWorld assembly

  • Put breakpoint inside SayHello method (in decompiled file)
  • Run debug in IIS express or IIS and request ~/Home/About page

Result: Brekpoint is never hit.

When I go to Debug -> Windows -> Modules it seems that symbols for HelloWorld.dll assembly was loaded: enter image description here

So, what am I doing wrong?

EDIT: I am using Visual Studio 2015 Update 1 and RedGate Reflector 8.5

like image 649
Ladislav Margai Avatar asked Jan 26 '16 12:01

Ladislav Margai


People also ask

How do I Debug a breakpoint in Visual Studio?

To set a breakpoint in source code: Click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint. The breakpoint appears as a red dot in the left margin.

How do I decompile DLL in Visual Studio?

To do this, go to the Modules window and from the context menu of a . NET assembly, and then select the Decompile source code command. Visual Studio generates a symbol file for the assembly and then embeds the source into the symbol file. In a later step, you can extract the embedded source code.


1 Answers

After hours and hours of research and contacting RedGate support it seems to be a bug in their software.

Workarounds:

  1. Use Visual Studio 2013, where it works as expected
  2. In VS 2015 go to .NET Reflector -> Generate PDBs and select C# version to v4.5. Reflector has some problems with C# version v4.6 Choose Assemblies to Debug
like image 116
Ladislav Margai Avatar answered Oct 13 '22 22:10

Ladislav Margai