Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# VS2012 stacktrace line is wrong

In my dll everything was OK for a long of time till today and I have no idea what's going wrong. There is wrong number of exception line appears from today.

So in my method inside dll library I insert a line to throw not supported exception but either I use a debugger or just see exception line in log line is wrong!

Here is an image of part of code : Stack problem

In fact exception is at 391 line and this was so long time till today. Now in log I see 776 line and the same at debugger. Does anybody has any ideas?

UPDATE 1 05/11/2013

After read all answers (thanks everybody for them =)) here is some update:

Is pdb file up to date? I think yes because I removed everything from output folder, rebuild solution and see the same issue. Also I checked creation date of it.

Am I in release mode? I think that not. Here is an image with build configuration
Build configuration

Is code optimized? I created one other test and removed everything below that NotSupportedException but issue is still at the end of the method and line is 397 but not 391 like we have in fact Debug test 2

What is an inner exception? Null inner ecxeption

like image 943
Vitalii Avatar asked Nov 04 '13 16:11

Vitalii


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr. Stroustroupe.

Is C language easy?

C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.

What is C language?

C is an imperative procedural language supporting structured programming, lexical variable scope, and recursion, with a static type system. It was designed to be compiled to provide low-level access to memory and language constructs that map efficiently to machine instructions, all with minimal runtime support.


1 Answers

I am almost positive you are running your program in release mode.

When you compile in release mode, the C# compiler will enable optimizations via the assembly's DebuggableAttribute.

The JIT compiler is smart and sees that all of the code between lines 394 and 776 are dead code, impossible to be reached because you're throwing a NotSupportedException.

Additionally, when we're in release mode, the pdb has limited information and JIT optimizations are enabled, so the compiler can't always map exception stacks to the exact location they've happened. It's usually not far off, though, to see where it was thrown.

like image 55
Christopher Currens Avatar answered Sep 23 '22 08:09

Christopher Currens