You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hello , I was following the minimal api documentation here
and got this error Unhandled exception. Cannot print exception string because Exception.ToString() failed.
Include your code
using Microsoft.EntityFrameworkCore;using NSwag.AspNetCore;varbuilder= WebApplication.CreateBuilder(args);
builder.Services.AddDbContext<TodoDb>(opt => opt.UseInMemoryDatabase("TodoList"));//DI?
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddOpenApiDocument(config =>{ config.DocumentName ="TodoAPI"; config.Title ="TodoAPI v1"; config.Version ="v1";});varapp= builder.Build();// GET
app.MapGet("/todoitems",async(TodoDbdb)=>await db.Todos.ToListAsync());// Get with filter
app.MapGet("/todoitems/complete",async(TodoDbdb)=>await db.Todos.Where(t => t.IsComplete).ToListAsync());
app.MapGet("/todoitems/{id}",async(intid,TodoDbdb)=>await db.Todos.FindAsync(id)is Todo todo? Results.Ok(todo): Results.NotFound());// Post
app.MapPost("/todoitems",async(Todotodo,TodoDbdb)=>{ db.Todos.Add(todo);await db.SaveChangesAsync();return Results.Created($"/todoitems/{todo.Id}", todo);});//Put for update
app.MapPut("/todoitems/{id}",async(intid,TodoinputTodo,TodoDbdb)=>{vartodo=await db.Todos.FindAsync(id);if(todo isnull)return Results.NotFound(); todo.Name = inputTodo.Name; todo.IsComplete = inputTodo.IsComplete;await db.SaveChangesAsync();return Results.NoContent();});// Delete
app.MapDelete("/todoitems/{id}",async(intid,TodoDbdb)=>{if(await db.Todos.FindAsync(id)is Todo todo){ db.Todos.Remove(todo);await db.SaveChangesAsync();return Results.NoContent();}return Results.NotFound();});// Entry point -- optional
app.MapGet("/",()=>"Hello World!");
app.MapGet("/users/{userId}/{postID}",(stringuserId,intpostID)=>$"The user id is {userId} and post id is {postID}");
app.Run();
Include stack traces
System.AggregateException: 'Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Microsoft.Extensions.Hosting.IHostApplicationLifetime Lifetime: Singleton ImplementationType: Microsoft.Extensions.Hosting.Internal.ApplicationLifetime': Could not load type 'System.Runtime.CompilerServices.NullableAttribute' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.) (Error while validating the service descriptor 'ServiceType: Microsoft.Extensions.Hosting.IHostLifetime Lifetime: Singleton ImplementationType: Microsoft.Extensions.Hosting.Internal.ConsoleLifetime': Could not load type 'System.Runtime.CompilerServices.NullableAttribute' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.) (Error while validating the service descriptor 'ServiceType: Microsoft.Extensions.Logging.ILoggerFactory Lifetime: Singleton ImplementationType: Microsoft.Extensions.Logging.LoggerFactory': Could not load type 'System.Runtime.CompilerServices.NullableAttribute' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Hosting.IApplicationLifetime Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Hosting.GenericWebHostApplicationLifetime': Could not load type 'System.Runtime.CompilerServices.NullableAttribute' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Connections.IConnectionListenerFactory Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportFactory': Could not load type 'System.Runtime.CompilerServices.NullableAttribute' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Server.Kestrel.Core.IHttpsConfigurationService Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Server.Kestrel.Core.HttpsConfigurationService': Could not load type 'System.Runtime.CompilerServices.NullableAttribute' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Hosting.Server.IServer Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl': Could not load type 'System.Runtime.CompilerServices.NullableAttribute' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Connections.IConnectionListenerFactory Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Server.Kestrel.Transport.NamedPipes.Internal.NamedPipeTransportFactory': Could not load type 'System.Runtime.CompilerServices.NullableAttribute' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Server.Kestrel.Core.HttpsConfigurationService+IInitializer Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Server.Kestrel.Core.HttpsConfigurationService+Initializer': Could not load type 'System.Runtime.CompilerServices.NullableAttribute' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Connections.IMultiplexedConnectionListenerFactory Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.QuicTransportFactory': Could not load type 'System.Runtime.CompilerServices.NullableAttribute' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Routing.Matching.DfaMatcherBuilder Lifetime: Transient ImplementationType: Microsoft.AspNetCore.Routing.Matching.DfaMatcherBuilder': Could not load type 'System.Runtime.CompilerServices.NullableAttribute' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Routing.LinkGenerator Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Routing.DefaultLinkGenerator': Could not load type 'System.Runtime.CompilerServices.NullableAttribute' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Routing.LinkParser Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Routing.DefaultLinkParser': Could not load type 'System.Runtime.CompilerServices.NullableAttribute' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Diagnostics.IDeveloperPageExceptionFilter Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseDeveloperPageExceptionFilter': Could not load type 'System.Runtime.CompilerServices.NullableAttribute' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.) (Error while validating the service descriptor 'ServiceType: Microsoft.Extensions.Hosting.IHostedService Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Hosting.GenericWebHostService': Could not load type 'System.Runtime.CompilerServices.NullableAttribute' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.)'
Include provider and version information
EF Core version:
Database provider: Microsoft.EntityFrameworkCore.UseInMemoryDatabase
Target framework: NET 8.0
Operating system: Windows 11 Pro
IDE: Visual Studio 2022 preview ( also vs code latest )
The text was updated successfully, but these errors were encountered:
This issue is lacking enough information for us to be able to fully understand what is happening. Please attach a small, runnable project or post a small, runnable code listing that reproduces what you are seeing so that we can investigate.
File a bug
hello , I was following the minimal api documentation here
and got this error
Unhandled exception. Cannot print exception string because Exception.ToString() failed.
Include your code
Include stack traces
Include provider and version information
EF Core version:
Database provider: Microsoft.EntityFrameworkCore.UseInMemoryDatabase
Target framework: NET 8.0
Operating system: Windows 11 Pro
IDE: Visual Studio 2022 preview ( also vs code latest )
The text was updated successfully, but these errors were encountered: