Cannot find reference assembly 'Microsoft.AspNetCore.Antiforgery.dll' file for package Microsoft.AspNetCore.Antiforgery
See original GitHub issueI use netcore 3.1 . when I use following code ,i got error.
var path = Path.Combine(_hostingEnvironment.ContentRootPath, "Views");
var engine = new RazorLightEngineBuilder()
.UseFileSystemProject(path)
.UseMemoryCachingProvider()
.Build();
var result = await engine.CompileRenderStringAsync("test", @"@using RazorLightTest.Controllers
@model Test
Hello @Model.Name", new Test { Name = "World" });
System.InvalidOperationException: Cannot find reference assembly 'Microsoft.AspNetCore.Antiforgery.dll' file for package Microsoft.AspNetCore.Antiforgery
at Microsoft.Extensions.DependencyModel.Resolution.ReferenceAssemblyPathResolver.TryResolveAssemblyPaths(CompilationLibrary library, List`1 assemblies)
at Microsoft.Extensions.DependencyModel.Resolution.CompositeCompilationAssemblyResolver.TryResolveAssemblyPaths(CompilationLibrary library, List`1 assemblies)
at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(ICompilationAssemblyResolver resolver, List`1 assemblies)
at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths()
at RazorLight.Compilation.DefaultMetadataReferenceManager.<>c.<Resolve>b__10_0(CompilationLibrary library)
at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
at RazorLight.Compilation.DefaultMetadataReferenceManager.Resolve(Assembly assembly, DependencyContext dependencyContext)
When i include the package “Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation”.The problem is solved.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:24 (3 by maintainers)
Top Results From Across the Web
c# - Cannot find reference assembly 'Microsoft.AspNetCore ...
1 Answer 1 ... Make sure you run command Ex. "dotnet publish -f netcoreapp2.1 -c Release" so you get a folder (bin\publish) which...
Read more >Microsoft.AspNetCore.Antiforgery.dll - code.fitness
Cannot find reference assembly 'Microsoft.AspNetCore.Antiforgery.dll' file for package Microsoft.AspNetCore.Antiforgery. Apr 8, 2020. It happened again.
Read more >no source - Cannot find reference assembly 'Microsoft. ...
Working fine locally with source code. Error: 4.60 - no source - Cannot find reference assembly 'Microsoft.AspNetCore.Antiforgery.dll' fail: Microsoft.
Read more >Why am I getting 'Unable to find package Microsoft. ...
I was working just fine yesterday but this morning I opened my project and began getting 'Unable to find package Microsoft.AspNetCore.
Read more >[Solved]-Copy Views folder for Asp.Net in .Net5-.net-core
InvalidOperationException: Cannot find reference assembly 'Microsoft.AspNetCore.Antiforgery.dll' file for package Microsoft.AspNetCore.Antiforgery.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Got the same error with netcore 3.0, adding this in my .csproj fixed the issue
Ref: https://github.com/aspnet/AspNetCore/issues/14418#issuecomment-535107767
@Wingjam I confirm it does, kudos!