简体   繁体   English

C#VS2012 stacktrace行错误

[英]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. 在我的dll中,直到今天,一切都还不错,我不知道出了什么问题。 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! 因此,在dll库中的方法中,我插入了一行以引发不支持的异常,但是我使用了调试器,或者只是看到日志行中的异常行是错误的!

Here is an image of part of code : 这是部分代码的图像: 堆栈问题

In fact exception is at 391 line and this was so long time till today. 实际上,例外是391行,到今天为止已经很长时间了。 Now in log I see 776 line and the same at debugger. 现在,在日志中,我看到776行,调试器中也是如此。 Does anybody has any ideas? 有人有什么想法吗?

UPDATE 1 05/11/2013 更新1 05/11/2013

After read all answers ( thanks everybody for them =) ) here is some update: 阅读完所有答案后( 感谢大家的支持=) ),下面是一些更新:

Is pdb file up to date? pdb文件是最新的吗? 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 这是带有构建配置的图像
构建配置

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 我创建了另一个测试,并删除了NotSupportedException以下的所有内容,但问题仍然在方法的末尾,行号是397,但不是391,就像我们实际上拥有的那样 调试测试2

What is an inner exception? 什么是内部例外? Null 空值 内分泌

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 . 在发布模式下进行编译时,C#编译器将通过程序集的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 . JIT编译器很聪明,可以看到394行和776行之间的所有代码都是无效代码,因为您抛出了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. 此外,当我们处于发布模式时,pdb的信息有限,并且启用了JIT优化,因此编译器无法始终将异常堆栈映射到它们发生的确切位置。 It's usually not far off, though, to see where it was thrown. 通常,离它不远处看看它被扔到了哪里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM