Fix TypeLoadException exception error#8157
Conversation
BenchmarksBenchmark execution time: 2026-02-04 17:17:07 Comparing candidate commit 483803f in PR branch Found 8 performance improvements and 6 performance regressions! Performance is the same for 162 metrics, 16 unstable metrics. scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net6.0
scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack netcoreapp3.1
scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net6.0
scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest netcoreapp3.1
scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net472
scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net6.0
scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces netcoreapp3.1
scenario:Benchmarks.Trace.DbCommandBenchmark.ExecuteNonQuery net472
scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark net6.0
scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog netcoreapp3.1
scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan netcoreapp3.1
scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes net472
scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin net6.0
|
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (8157) and master. ✅ No regressions detected - check the details below Full Metrics ComparisonFakeDbCommand
HttpMessageHandler
Comparison explanationExecution-time benchmarks measure the whole time it takes to execute a program, and are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are highlighted in **red**. The following thresholds were used for comparing the execution times:
Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard. Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph). Duration chartsFakeDbCommand (.NET Framework 4.8)gantt
title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8157) - mean (68ms) : 67, 70
master - mean (68ms) : 67, 70
section Bailout
This PR (8157) - mean (72ms) : 71, 73
master - mean (72ms) : 71, 73
section CallTarget+Inlining+NGEN
This PR (8157) - mean (1,036ms) : 965, 1108
master - mean (1,034ms) : 975, 1093
FakeDbCommand (.NET Core 3.1)gantt
title Execution time (ms) FakeDbCommand (.NET Core 3.1)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8157) - mean (115ms) : 113, 117
master - mean (115ms) : 112, 118
section Bailout
This PR (8157) - mean (116ms) : 115, 117
master - mean (116ms) : 114, 117
section CallTarget+Inlining+NGEN
This PR (8157) - mean (795ms) : 738, 852
master - mean (792ms) : 739, 846
FakeDbCommand (.NET 6)gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8157) - mean (101ms) : 98, 104
master - mean (101ms) : 98, 103
section Bailout
This PR (8157) - mean (102ms) : 100, 103
master - mean (101ms) : 100, 102
section CallTarget+Inlining+NGEN
This PR (8157) - mean (771ms) : 750, 791
master - mean (768ms) : 749, 787
FakeDbCommand (.NET 8)gantt
title Execution time (ms) FakeDbCommand (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8157) - mean (100ms) : 98, 102
master - mean (99ms) : 97, 101
section Bailout
This PR (8157) - mean (101ms) : 100, 102
master - mean (100ms) : 99, 102
section CallTarget+Inlining+NGEN
This PR (8157) - mean (687ms) : 672, 703
master - mean (675ms) : 655, 694
HttpMessageHandler (.NET Framework 4.8)gantt
title Execution time (ms) HttpMessageHandler (.NET Framework 4.8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8157) - mean (220ms) : 202, 237
master - mean (213ms) : 200, 226
section Bailout
This PR (8157) - mean (220ms) : 207, 234
master - mean (216ms) : 203, 229
section CallTarget+Inlining+NGEN
This PR (8157) - mean (1,234ms) : 1161, 1307
master - mean (1,224ms) : 1165, 1283
HttpMessageHandler (.NET Core 3.1)gantt
title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8157) - mean (316ms) : 304, 328
master - mean (323ms) : 312, 334
section Bailout
This PR (8157) - mean (321ms) : 311, 331
master - mean (325ms) : 312, 339
section CallTarget+Inlining+NGEN
This PR (8157) - mean (1,057ms) : 1007, 1107
master - mean (1,081ms) : 1014, 1148
HttpMessageHandler (.NET 6)gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8157) - mean (308ms) : 296, 319
master - mean (318ms) : 293, 343
section Bailout
This PR (8157) - mean (314ms) : 297, 331
master - mean (324ms) : 292, 356
section CallTarget+Inlining+NGEN
This PR (8157) - mean (1,050ms) : 1002, 1097
master - mean (1,088ms) : 972, 1203
HttpMessageHandler (.NET 8)gantt
title Execution time (ms) HttpMessageHandler (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (8157) - mean (309ms) : 297, 320
master - mean (309ms) : 294, 324
section Bailout
This PR (8157) - mean (311ms) : 295, 328
master - mean (310ms) : 293, 326
section CallTarget+Inlining+NGEN
This PR (8157) - mean (1,016ms) : 893, 1138
master - mean (1,020ms) : 890, 1150
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Summary of changes
Fixes
TypeLoadExceptionbeing logged as an error during tracer initialization on .NET Framework whenSystem.Web.Hosting.HostingEnvironmentis unavailable.Reason for change
On .NET Framework 4.x, users were seeing this error during startup:
Root Cause
The existing code had a
try-catchblock insideTryLoadAspNetSiteNameto catchTypeLoadException, but the exception was thrown during JIT compilation of the method, not during execution. When the JIT compiler encounteredSystem.Web.Hosting.HostingEnvironmentreferences, it threwTypeLoadExceptionbefore any code in the method could execute - so the inner catch block was never reached.Implementation details
Extracted the
System.Web-dependent code into a separate method marked with[MethodImpl(MethodImplOptions.NoInlining)]. This:TypeLoadExceptionto be caught at the call siteA similar pattern is already used in
SecurityCoordinator.Framework.cs:243-244.Test coverage
Other details