I've been trying to import in a ASP.NET Core MVC view of the already compiled view *.Views.dll between the possible views.
Caution!
I have no intention of adding the *.views.dll file among the resources being compiled but afterwards.
To make things clear, the running program must take the file from a folder and read it by adding the contents of the assembly file to its views
To get more information I'll give you the link of the speech in the qule is connected
In addition I do not want to use the embedded resource because the view remains clear.
I tried this
services.AddMvc().ConfigureApplicationPartManager(apm =>{
var part = new AssemblyPart(AssemblyLoadContext.Default.LoadFromAssemblyPath("C:\\Users\\gianf\\source\\repos\\ViewTestPlugin2\\plug\\bin\\Debug\\netcoreapp2.1\\plug.Views.dll"));
apm.ApplicationParts.Add(part);
});
Resolved!!!
looking at the assembly of the * .views.dll file I noticed this
[assembly: ProvideApplicationPartFactory("Microsoft.AspNetCore.Mvc.ApplicationParts.CompiledRazorAssemblyApplicationPartFactory, Microsoft.AspNetCore.Mvc.Razor")]
so as a result I tried to manually set it like this:
services.AddMvc().ConfigureApplicationPartManager(apm =>
{
var a = new CompiledRazorAssemblyApplicationPartFactory();
foreach (var b in a.GetApplicationParts(AssemblyLoadContext.Default.LoadFromAssemblyPath("C:\\Users\\gianf\\source\\repos\\ViewTestPlugin2\\plug\\bin\\Debug\\netcoreapp2.1\\plug.Views.dll")))
apm.ApplicationParts.Add(b);
});
and so it works, I think AssemblyPart is broken
Mainmethod. Also make sure to use `AssemblyLoadContext.Default' as according to this only from there it will be discovered by the DI/IoC system