我从 ASP.NET 应用程序返回的堆栈跟踪(从 ArgumentNullException 生成)给人的印象是下面代码的最后一行发生了错误。据我所知,这是不可能的,但如果 JIT 优化了对 的调用Bar
,这将导致不同的堆栈跟踪,它会解释一切。我确定它不是 c# 编译器,因为 CIL 看起来像我所期望的那样。JIT 编译器是否有可能删除对 Bar 的调用?
c# 4,.NET 4.0.30319.1,ASP.NET 4.0.30319.1
编辑: 我应该提到这是一个发布配置,Optimize code = on,Debug Info = pdb-only。
Stack Trace:
[ArgumentNullException: Value cannot be null. Parameter name: value]
CreateHiddenField(HtmlTextWriter tr, String name, String value) in Foo.cs:129
Foo(IHttpContext context, HtmlTextWriter writer) in Foo.cs:106
private static void Foo(IHttpContext context, HtmlTextWriter writer)
{ // line 103
Bar(writer, AuthorizationServerResponseDetailsHttpRequestParser.RequestSAMLFieldName, context);
Bar(writer, AuthorizationServerResponseDetailsHttpRequestParser.RequestTargetFieldName, context);
// line 106 - blank line in source code.
CreateHiddenField(tr, name, string.Empty); // looks like its here
}
private static void Bar(HtmlTextWriter tr,string name, IHttpContext context)
{ // line 116
#region Sanitation
if (tr == null) { throw new System.ArgumentNullException("tr"); }
if (name == null) { throw new System.ArgumentNullException("name"); }
if (context == null) { throw new System.ArgumentNullException("context"); }
#endregion
CreateHiddenField(tr, name, context.RequestQueryString(name));
}
private static void CreateHiddenField(HtmlTextWriter tr, string name, string value)
{ // line 127
#region Sanitation
if (tr == null) { throw new System.ArgumentNullException("tr"); }
if (name == null) { throw new System.ArgumentNullException("name"); }
if (value == null) { throw new System.ArgumentNullException("value"); }
#endregion
// payload...
}