I am trying to load parts of an application into an ASP.NET Core 2.0 MVC appication using a package System.Runtime.Loader, but it will not allow me.
The error message says:
FileNotFoundException: Failed to load the file or assembly "System.Runtime.Loader, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a" or one of its dependencies. The system cannot find the specified file.
In Startup.csI use it like this (it should just be a proof of concept that this works, so I can move it to a dedicated class or extension):
services
.AddMvc()
.ConfigureApplicationPartManager(apm =>
{
var parts = Directory.GetFiles(_rootPath, "*.Part.*");
foreach (var part in parts)
{
apm.ApplicationParts.Add(new AssemblyPart(AssemblyLoadContext.Default.LoadFromAssemblyPath(part)));
}
});
The installed package has a version 4.3.0, and I use it in ASP.NET Core 2.0 with .NET 4.6.2.
, - , runtime app.config
<runtime>
<gcServer enabled="true"/>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<publisherPolicy apply="no"/>
<assemblyIdentity name="System.Runtime.Loader" publicKeyToken="b03f5f7f11d50a3a" culture="en-US"/>
<bindingRedirect oldVersion="4.3.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
. , 1.0.0.0-5.0.0.0, .
, IE, - :
WebApiProject.Startup.<ConfigureServices>b__8_1(ApplicationPartManager apm)
Microsoft.Extensions.DependencyInjection.MvcCoreMvcBuilderExtensions.ConfigureApplicationPartManager(IMvcBuilder builder, Action<ApplicationPartManager> setupAction)
WebApiProject.Startup.ConfigureServices(IServiceCollection services) in Startup.cs
-
38. public IHostingEnvironment Environment { get; }
39.
40.
41. public void ConfigureServices(IServiceCollection services)
42. {
43.
44. services
45. .AddMvc()
...
50. .ConfigureApplicationPartManager(apm =>
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceColection services)
Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
System.Runtime.*, System.Runtime.Loader. , , ? , .dll , VS ?
Update
, . . NuGet , , packages , :
c:\Users\%USER%\.nuget\packages\system.runtime.loader\4.3.0\lib\
, net462. : _
, .dll:
MonoAndroid10\
MonoTouch10\
net462\
netstandard1.5\ <-- System.Runtime.Loader.dll
xamarinios10\
xamarinmac20\
xamarintvos10\
xamarinwatchos10\
? , , *.dll , ? , , .net ?
- , ?