I am making an .NET Core application and I wanted to start an app but it says at this line of code:
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
endpoints.MapRazorPages();
});
//...
it says this error:
System.TypeInitializationException: 'The type initializer for 'Microsoft.AspNetCore.Mvc.MvcCoreLoggerExtensions' threw an exception.'
that is something new and I never seen that before while starting an application. How can I fix it?
Inner exception is:
Method not found: 'System.Action`4<Microsoft.Extensions.Logging.ILogger,!!0,!!1,System.Exception> Microsoft.Extensions.Logging.LoggerMessage.Define(Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId, System.String, Boolean)'.
Main.cs
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
.NET Core 6.0 is the latest version
Identity is included into application.
You need to update Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
Faced the same problem, created MVC Proj with razor template project in VS2022 was using 6.0.0-preview.5.21301.17
so I updated package to 6.0.0-preview.7.21378.6
This can be linked to an compatebility issue on the Microsoft.AspNetCore.Authentication.Negotiate with the installed EF library.
Update the following libraries (using Nuget)
This will probably solve the issue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With