Pavel Jedlicka
Pavel Jedlicka

Reputation: 585

ASP.NET Core missing line numbers in exception

I created new project: ASP.NET Core Web Application (.NET Core) and test throw new exception in controller and catch the exception. In exception is no line numbers (exception.ToString()). I added System.Diagnostics.StackTrace to project.json, but line numbers are still missing, even with debugger.

When I change Core framework project to full .NET framework, line numbers are OK. Can I get line numbers of exception in Core framework?

Upvotes: 7

Views: 3095

Answers (3)

Vidyesh
Vidyesh

Reputation: 563

For me, enabling Portable PDB or setting Optimize didn't fix the problem.

But I tried changing the Debugging information to "Full" in Advanced Build Settings and it worked.

Follow the below procedure:

  1. Open the "Properties" of your startup project.
  2. Goto "Build".
  3. Click on "Advanced" under Output section.
  4. Change the Debugging information to "Full".

enter image description here

Upvotes: 13

lxa
lxa

Reputation: 3332

I had a similar problem: in release build, instead of proper line numbers I was getting line 0 in stack traces; fixed by disabling optimizations; in project.json:

"configurations": {
    "Release": {
        "buildOptions": {
            "optimize": false
        }
    }
}

Upvotes: 0

Pavel Jedlicka
Pavel Jedlicka

Reputation: 585

When I enable portable PDBs in Core framework -> line numbers are back :-)

Enable portable PDBs in project.json:

"buildOptions": {
"debugType": "portable",
...
},

Upvotes: 2

Related Questions