Thomas Ardal

Thomas Ardal

Meet Thomas, the founder and developer behind elmah.io. Thomas blogs about everything technical from C# and ASP.NET Core to machine learning.

Denmark
320 posts
Find anomalies with spike detection and ML.NET

A real elmah.io example of untrained anomaly detection using ML.NET Microsoft.ML and Microsoft.ML.TimeSeries NuGet packages: feeding a time series like 0,1,1,0,2,1,0,0,1,1,50,0 into an MLContext-based estimator, with a VectorType(3) double array output flagging the value 50 as a spike. ...

Debugging System.NullReferenceException - Object reference not set to an instance of an object

Walks through pinpointing which link in a chain like service.GetUser().Address.Street is null when debugging System.NullReferenceException: splitting the call across lines, using Visual Studio Null Reference Analysis via Debug > Windows > Exception Settings, and fixing it with nested null checks. ...

How to write to a file with C# - StackOverflow doesn't get it right

Benchmarks ways to write text to a file in C#: File.WriteAllText (about 100ms for 1 million lines), File.CreateText StreamWriter for batched writes, File.AppendAllText/AppendAllLines and AppendText for appending, and FileStream for async writes, warning against reopening AppendText in a loop. ...

C# exception handling best practices

Five C# exception-handling practices: use throw; instead of throw specificException; to preserve the stack trace, stash context in Exception.Data (visible in elmah.io Data tab), and catch ArgumentException/DirectoryNotFoundException before a generic Exception, tagging errors with a support-id Guid. ...

Fix max URL and query string length with web.config and IIS

Diagnoses an HTTP 404.15 query-string-too-long error from IIS default request-filtering limits (maxUrl 4096 chars, maxQueryString 2048 chars), fixed by raising requestLimits maxQueryString to 8192 in web.config system.webServer/security, or httpRuntime maxQueryStringLength on older sites. ...

OAuth authentication with Facebook and ASP.NET Core

Sets up ASP.NET Core 3.0 Identity authentication from the Visual Studio template: running Update-Database and Add-Migration CreateIdentitySchema to scaffold the schema, then building a custom EmailSender using System.Net.Mail with a local Smtp4Dev server, ahead of adding Facebook OAuth login. ...

Partner with BrowserStack to support real-device debugging

Announces an elmah.io integration with BrowserStack (since removed) that let you relaunch a failing error URL on the exact physical device and OS/browser combination parsed from its user agent, directly from the error page, with a 30-minute free BrowserStack trial before any paid subscription. ...

Migrating the elmah.io API to ASP.NET Core

Details elmah.io API rewrite from ASP.NET Web API to ASP.NET Core, backward compatible with Elmah.Io.Client 3.x: errors return RFC 7807 Problem Details with an application/problem+json body (title/status/detail), an upgraded Swagger UI, and CORS enabled on every endpoint, not just message creation. ...

Structured logging vNext

Announces that elmah.io now stores the original templated log message (e.g. {user} says hello) alongside the formatted text, enabling search on the messageTemplate field and template-based alert rules, in prerelease Serilog.Sinks.ElmahIo, Elmah.Io.NLog, and Elmah.Io.Extensions.Logging packages. ...