Home > other >  When upgrading to .NET 6, Web Project throws runtime exception
When upgrading to .NET 6, Web Project throws runtime exception

Time:11-17

Using an existing .NET 5 MVC Web App, I attempted to upgrade to .NET 6, but encountered this error. I am also using IIS for Windows Authentication--now setup in .NET 6 as "profiles" under Properties -> Debug -> hyperlink (Open debug launch profiles UI). I also included the newer "Microsoft.AspNetCore.Authentication.Negotiate" Nuget package (and associated code) to handle the newer Windows Authentication library.

When the web app launches, I get the following error:

An unhandled exception occurred while processing the request.

InvalidOperationException: Cannot find compilation library location for package 'System.Security.Cryptography.Pkcs'

Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(ICompilationAssemblyResolver resolver, List assemblies) Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths() Microsoft.AspNetCore.Mvc.ApplicationParts.AssemblyPartExtensions <>c.b__0_0(CompilationLibrary library) System.Linq.Enumerable SelectManySingleSelectorIterator<TSource, TResult>.MoveNext()

...

Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

This does NOT go away if I add the package listed: System.Security.Cryptography.Pkcs

CodePudding user response:

I needed to remove at least 1 Nuget package:

  1. Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation -- I removed this one second, but it started working after I did.
  2. Microsoft.Extensions.Hosting -- I removed this one first, but this alone did not fix it. I don't know if this "also" needed to be removed. I assume not, but I'm including, just in case. Removing it did not hurt anything.

Microsoft.AspNetCore.Mvc>Razor.RuntimeCompilation

  • Related