diff --git a/src/Openchain.Server/Models/DependencyResolver.cs b/src/Openchain.Server/Models/DependencyResolver.cs index cf134b2..02bd424 100644 --- a/src/Openchain.Server/Models/DependencyResolver.cs +++ b/src/Openchain.Server/Models/DependencyResolver.cs @@ -17,11 +17,11 @@ using System.IO; using System.Linq; using System.Reflection; -using System.Runtime.Loader; using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyModel; using Microsoft.Extensions.Logging; using Openchain.Infrastructure; @@ -91,13 +91,9 @@ public async Task> Build() private static IList LoadAllAssemblies(string projectPath) { - return Directory.EnumerateFiles(projectPath) - .Where(name => - Path.GetFileName(name).StartsWith("Openchain.", StringComparison.OrdinalIgnoreCase) - && Path.GetFileNameWithoutExtension(name) != "Openchain.Server" - && !Path.GetFileNameWithoutExtension(name).Equals("Openchain", StringComparison.OrdinalIgnoreCase) - && Path.GetExtension(name).Equals(".dll", StringComparison.OrdinalIgnoreCase)) - .Select(file => AssemblyLoadContext.Default.LoadFromAssemblyPath(Path.Combine(projectPath, file))) + return DependencyContext.Default.RuntimeLibraries + .Where(library => library.Name.StartsWith("Openchain.", StringComparison.OrdinalIgnoreCase)) + .Select(library => Assembly.Load(new AssemblyName(library.Name))) .ToList(); } } diff --git a/src/Openchain.Server/project.json b/src/Openchain.Server/project.json index 573376d..e22842b 100644 --- a/src/Openchain.Server/project.json +++ b/src/Openchain.Server/project.json @@ -17,7 +17,6 @@ }, "dependencies": { - "System.Runtime.Loader": "4.0.0", "Microsoft.AspNetCore.Mvc.Cors": "1.0.0", "Microsoft.AspNetCore.Mvc.Core": "1.0.0", "Microsoft.AspNetCore.Mvc.ViewFeatures": "1.0.0", @@ -41,6 +40,9 @@ "dnxcore50", "portable-net45+win8" ] + }, + + "net451": { } } }