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
{{ message }}
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
After upgrading to the latest preview release, I am now seeing the following error when starting up the application (via dotnet run):
System.InvalidOperationException: Unable to activate type 'Microsoft.AspNetCore.Mvc.Razor.Internal.FileProviderRazorProject'. The following constructors are ambigious:
Void .ctor(Microsoft.AspNetCore.Mvc.Razor.Internal.IRazorViewEngineFileProviderAccessor)
Void .ctor(Microsoft.Extensions.FileProviders.IFileProvider)
Thanks for this report. FileProviderRazorProject is a infrastructure type for the view engine, and it has two constructors - the IFileProvider constructor is used for our unit tests. We intend the IRazorViewEngineFileProviderAccessor to be used in product scenarios.
We didn't anticipate this, but it looks like something we'll need to fix in 2.0.0.
For now if you want a workaround, for preview 2 you can add the following to your ConfigureServices
services.AddSingleton<RazorProject>(s =>
{
return new FileProviderRazorProject(s.GetRequiredService<IRazorViewEngineFileProviderAccessor>());
});
The RazorProject implementation used by MVC at runtime has a constructor
that takes an IFileProvider (used by tests). This causes ambiguities
when a user registers an IFileProvider in DI.
Cleaning up tests to use a mock instead of the file provider directly
After upgrading to the latest preview release, I am now seeing the following error when starting up the application (via dotnet run):
System.InvalidOperationException: Unable to activate type 'Microsoft.AspNetCore.Mvc.Razor.Internal.FileProviderRazorProject'. The following constructors are ambigious:
Void .ctor(Microsoft.AspNetCore.Mvc.Razor.Internal.IRazorViewEngineFileProviderAccessor)
Void .ctor(Microsoft.Extensions.FileProviders.IFileProvider)
My application registers its own IFileProvider as part of startup, like this (also suggested here: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/file-providers):
.AddSingleton(x => new PhysicalFileProvider(_config["Environment:AssetsPath"]))
If I comment out this line, then everything starts normally, but of course the functionality depending on this does not work.
Should this still work as before?
-- dotnet info:
.NET Command Line Tools (2.0.0-preview2-006497)
Product Information:
Version: 2.0.0-preview2-006497
Commit SHA-1 hash: 06a2093335
Runtime Environment:
OS Name: fedora
OS Version: 25
OS Platform: Linux
RID: fedora.25-x64
Base Path: /opt/dotnet/sdk/2.0.0-preview2-006497/
Microsoft .NET Core Shared Framework Host
Version : 2.0.0-preview2-25407-01
Build : 40c565230930ead58a50719c0ec799df77bddee9
The text was updated successfully, but these errors were encountered: