.NET errors

.NET runtime and ASP.NET Core exceptions.

CodeErrorWhat it means
FileNotFoundException assembly Could not load file or assembly 'X, Version=…' or one of its dependencies The runtime couldn’t find or load a referenced DLL — missing from the output, wrong version, or wrong platfor…
Unable to cast object of type System.InvalidCastException: Unable to cast object of type 'X' to type 'Y' An explicit cast failed because the object’s runtime type isn’t the target type.
NullReferenceException System.NullReferenceException: Object reference not set to an instance of an object Code dereferenced a variable that is `null` — the .NET equivalent of Java’s NullPointerException.
Cannot access a disposed context instance ObjectDisposedException: Cannot access a disposed context instance Code used a DbContext after its scope ended — usually async void, fire-and-forget tasks, or capturing a scope…
Index was out of range ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection Code accessed a List/collection position that doesn’t exist (IndexOutOfRangeException for arrays).
InvalidOperationException InvalidOperationException: Unable to resolve service for type 'X' while attempting to activate 'Y' ASP.NET Core’s dependency injection container can’t build Y because one of its constructor dependencies (X) w…
Access to the path is denied System.UnauthorizedAccessException: Access to the path 'x' is denied The process’s identity can’t read/write that file or folder — IIS app pool identity, container user, read-onl…
Input string was not in a correct format System.FormatException: Input string was not in a correct format int.Parse/decimal.Parse/Convert.ToInt32 got a string that isn’t a valid number — empty, contains text, or use…
NU1101 error NU1101: Unable to find package X. No packages exist with this id in source(s): nuget.org NuGet restore can’t find the package in any configured source — typo, private feed not configured/authenticat…
HttpClient.Timeout TaskCanceledException: The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing The HTTP call took longer than HttpClient.Timeout (100 s default), so .NET cancelled it.
500.30 HTTP Error 500.30 - ASP.NET Core app failed to start IIS/Azure’s ASP.NET Core Module launched your app but it crashed during startup.
An unhandled error has occurred Blazor: An unhandled error has occurred. Reload 🗙 A Blazor component threw an exception; Blazor Server tears down the circuit (or WebAssembly logs to the conso…
NU1605 error NU1605: Detected package downgrade: X from 8.0.1 to 8.0.0. Reference the package directly from the project to select a different version A direct reference requests a lower version than a dependency needs, and NuGet treats the downgrade as an err…
DbUpdateException DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details. SaveChanges failed in the database; the inner exception (SqlException/PostgresException) has the real reason…
requires a primary key to be defined EF Core: The entity type 'X' requires a primary key to be defined EF Core found an entity class without a key property it can recognise.
IDX20803 IDX20803: Unable to obtain configuration from: 'https://login.example.com/.well-known/openid-configuration' The OpenID Connect / JWT bearer middleware couldn’t download the identity provider’s metadata, so it can’t va…
IDX10223 Bearer error="invalid_token": IDX10223: Lifetime validation failed. The token is expired / IDX10501: Signature validation failed ASP.NET Core’s JwtBearer middleware rejected the token — expired (IDX10223), signature key not found (IDX1050…
ConnectionString property has not been initialized InvalidOperationException: The ConnectionString property has not been initialized The database connection was opened with an empty connection string — the configuration key wasn’t found.
is an invalid start of a value System.Text.Json: '<' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0 The response wasn’t JSON — usually an HTML error page, login redirect, or an empty body was passed to the JSO…
Unable to create a 'DbContext' dotnet ef: Unable to create a 'DbContext' of type ''. The exception 'Unable to resolve service for type DbContextOptions' was thrown while attempting to create an instance dotnet ef migrations couldn’t construct your DbContext at design time.
CS0103 error CS0103: The name 'x' does not exist in the current context The identifier isn’t declared in scope — typo, variable declared in another block, missing using static, or a…
NETSDK1045 error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0. Either target .NET 7.0 or lower, or use a version of the .NET SDK that supports .NET 8.0 The installed .NET SDK is older than the project’s TargetFramework.
Session has not been configured InvalidOperationException: Session has not been configured for this application or request Code used HttpContext.Session, but session services/middleware aren’t registered — or UseSession runs after t…
Failed to complete negotiation with the server SignalR: Error: Failed to complete negotiation with the server / Failed to start the connection The SignalR client couldn’t negotiate with the hub — wrong URL, CORS, authentication, or a proxy that blocks…
You must install or update .NET to run this application The framework 'Microsoft.NETCore.App', version '8.0.0' (x64) was not found. You must install or update .NET to run this application The machine doesn’t have the .NET runtime version the app was built for (framework-dependent deployment).
CS1061 error CS1061: 'X' does not contain a definition for 'Y' and no accessible extension method 'Y' accepting a first argument of type 'X' could be found The member you call doesn’t exist on that type — typo, wrong type, missing using for an extension method, or…
MSB3027 error MSB3027: Could not copy "obj\...\App.dll" to "bin\...\App.dll". Exceeded retry count of 10. The file is locked by: "App (1234)" The build can’t overwrite the output DLL/EXE because the app (or IIS Express, a test runner, antivirus) is st…
500.19 HTTP Error 500.19 - Internal Server Error: The requested page cannot be accessed because the related configuration data for the page is invalid IIS can’t read web.config — usually the ASP.NET Core Hosting Bundle (AspNetCoreModuleV2) or URL Rewrite modul…
actively refused it HttpRequestException: No connection could be made because the target machine actively refused it (localhost:5001) Nothing is listening on the host/port the client called — the API isn’t running, uses another port, or the co…
JsonException object cycle JsonException: A possible object cycle was detected System.Text.Json found a reference loop (e.g. Order → Customer → Orders → …) while serialising, usually from…
Unexpected character encountered while parsing value Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0 Json.NET was given text that isn’t valid JSON — commonly HTML, a BOM, or an already-serialized string.
Failed to bind to address System.IO.IOException: Failed to bind to address http://127.0.0.1:5000: address already in use Kestrel can’t listen because another process (often a previous run of the same app) uses the port.
The JSON value could not be converted System.Text.Json.JsonException: The JSON value could not be converted to System.Int32. Path: $.id System.Text.Json couldn’t map a JSON value to the target .NET type — e.g. "42" (string) to int, null to a non…
The request matched multiple endpoints AmbiguousMatchException: The request matched multiple endpoints. Matches: X, Y Two controller actions or minimal API endpoints have the same route and HTTP method.
A second operation was started on this context EF Core: A second operation was started on this context instance before a previous operation completed The same DbContext was used concurrently — async calls not awaited, parallel tasks sharing a context, or a co…
CS0246 error CS0246: The type or namespace name 'X' could not be found (are you missing a using directive or an assembly reference?) The compiler doesn’t know the type — missing using, missing NuGet package/project reference, or a target fram…
Sequence contains no elements InvalidOperationException: Sequence contains no elements / more than one element LINQ `First()`, `Single()`, `Last()` or `Max()` ran on an empty sequence (or `Single()` found several items).
System.Drawing.Common is not supported PlatformNotSupportedException: System.Drawing.Common is not supported on this platform Since .NET 6, System.Drawing.Common only works on Windows; on Linux/macOS (including Docker) it throws.
Stack overflow .NET: Stack overflow. / Process is terminated due to StackOverflowException Infinite or very deep recursion exhausted the thread’s stack; .NET can’t catch it and terminates the process.
CORS wildcard with credentials ASP.NET Core: The CORS protocol does not allow specifying a wildcard (any) origin and credentials at the same time The CORS policy uses AllowAnyOrigin() together with AllowCredentials(), which browsers forbid.
The LINQ expression could not be translated EF Core: The LINQ expression 'x' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly The query uses C# code EF Core can’t convert to SQL — custom methods, unsupported string/date functions, or c…
No authenticationScheme was specified InvalidOperationException: No authenticationScheme was specified, and there was no DefaultChallengeScheme found [Authorize] triggered a challenge, but no authentication handler/default scheme is configured.
No database provider has been configured InvalidOperationException: No database provider has been configured for this DbContext EF Core created a DbContext without UseSqlServer/UseNpgsql/UseSqlite — typically because the context was newe…
OutOfMemoryException System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown The process couldn’t allocate memory — large in-memory data, leaks, 32-bit process limits, or container memor…
antiforgery token could not be decrypted ASP.NET Core: The antiforgery token could not be decrypted / The required antiforgery cookie is not present (400 Bad Request) Form POST failed antiforgery validation — the token is missing, the cookie is missing, or Data Protection key…
The SSL connection could not be established HttpRequestException: The SSL connection could not be established, see inner exception. (AuthenticationException: The remote certificate is invalid) HttpClient couldn’t complete the TLS handshake — untrusted/self-signed certificate, name mismatch, expired ce…
Collection was modified InvalidOperationException: Collection was modified; enumeration operation may not execute A list/dictionary was changed while a foreach loop was iterating it.
cannot be tracked because another instance with the same key The instance of entity type 'X' cannot be tracked because another instance with the same key value for {'Id'} is already being tracked Two different objects with the same primary key were attached to one DbContext.
Unable to configure HTTPS endpoint Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date Kestrel was told to listen on HTTPS but has no certificate — the ASP.NET Core dev certificate is missing/expi…
CS8618 warning CS8618: Non-nullable property 'X' must contain a non-null value when exiting constructor. Consider declaring the property as nullable With nullable reference types enabled, a non-nullable reference property isn’t initialised by the constructor.