Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find reference assembly 'Microsoft.AspNetCore.Antiforgery.dll' while using a FileProviders in net core 3 #14418

Closed
fpanaccia opened this issue Sep 25, 2019 · 4 comments
Assignees
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Milestone

Comments

@fpanaccia
Copy link

Hi, i have a library that render views and with the html makes a pdf.

When using the Physical Views (the ones that you have in the project) everything works fine.
But when using the fileprovider i get the following error, this was working fine in 2.1

image

I have tried some debuggin of the .net libraries and the farthest i can go without breaking was here.

The code is in this repo https://github.com/fpanaccia/Wkhtmltopdf.NetCore.Example.git and the branch is feature/3.0

namespace Microsoft.AspNetCore.Mvc.Razor.Compilation
internal class DefaultRazorPageFactoryProvider : IRazorPageFactoryProvider
public RazorPageFactoryResult CreateFactory(string relativePath)
line 44 var viewDescriptor = compileTask.GetAwaiter().GetResult();

To Reproduce

Steps to reproduce the behavior:

  1. Download the Repo and the branch
  2. Open the Rotativa.sln
  3. Run it and go to http://localhost:54460/TestDynamicViews/GetByteArray
  4. See error

Expected behavior

Render the View and make the pdf (this is the result with the view in the project) it should have the same result
image

@javiercn javiercn added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Sep 25, 2019
@pranavkm pranavkm self-assigned this Sep 25, 2019
@pranavkm
Copy link
Contributor

@fpanaccia with runtime compilation off by default, the 3.0 SDK avoids copying references to the build output that is needed for runtime compilation. To turn this back on, set these properties in your project file:

<PropertyGroup>
    <PreserveCompilationReferences>true</PreserveCompilationReferences>
    <PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>

@pranavkm pranavkm added this to the Discussions milestone Sep 25, 2019
@fpanaccia
Copy link
Author

@pranavkm Hi, thanks!, adding those parameters to the project that uses the library, it worked, but, everyone that uses the library will have to set these properties, there is another way to do it?

@pranavkm
Copy link
Contributor

You could update the package to include build targets that specify these properties. That's essentially what the runtime compilation package does:

https://github.com/aspnet/AspNetCore/blob/release/3.1/src/Mvc/Mvc.Razor.RuntimeCompilation/src/build/netcoreapp3.0/Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.targets#L3-L4

@fpanaccia
Copy link
Author

Thanks! i will try later!, i will close the issue, and if that doesn't work (i'm sure it will), i will re open the issue, thanks again!

@ghost ghost locked as resolved and limited conversation to collaborators Dec 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Projects
None yet
Development

No branches or pull requests

3 participants