From 429b3d84e684e042127a9d50a3afe58c913cef45 Mon Sep 17 00:00:00 2001 From: Vegard Andreas Larsen Date: Thu, 2 Jul 2020 13:51:20 +0200 Subject: [PATCH] Fix not working with .NET Framework 4.7.2 System.Runtime.Loader is not supported on .NET Framework 4.7.2. We need to use Assembly.LoadFrom instead. --- .../Interop/ComInterfaceAssemblyProvider.cs | 8 +++++++- source/VirtualDesktop/VirtualDesktop.csproj | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/source/VirtualDesktop/Interop/ComInterfaceAssemblyProvider.cs b/source/VirtualDesktop/Interop/ComInterfaceAssemblyProvider.cs index f0bf364..af5be6e 100644 --- a/source/VirtualDesktop/Interop/ComInterfaceAssemblyProvider.cs +++ b/source/VirtualDesktop/Interop/ComInterfaceAssemblyProvider.cs @@ -3,7 +3,9 @@ using System.IO; using System.Linq; using System.Reflection; +#if !NETFRAMEWORK using System.Runtime.Loader; +#endif using System.Text; using System.Text.RegularExpressions; using WindowsDesktop.Properties; @@ -22,7 +24,7 @@ internal class ComInterfaceAssemblyProvider private static readonly Version _requireVersion = new Version("1.0"); private readonly string _assemblyDirectoryPath; - + public ComInterfaceAssemblyProvider(string assemblyDirectoryPath) { this._assemblyDirectoryPath = assemblyDirectoryPath ?? _defaultAssemblyDirectoryPath; @@ -135,7 +137,11 @@ private Assembly Compile(IEnumerable sources) var result = compilation.Emit(path); if (result.Success) { +#if NETFRAMEWORK + return Assembly.LoadFrom(path); +#else return AssemblyLoadContext.Default.LoadFromAssemblyPath(path); +#endif } File.Delete(path); diff --git a/source/VirtualDesktop/VirtualDesktop.csproj b/source/VirtualDesktop/VirtualDesktop.csproj index bc0de6c..a33b0ae 100644 --- a/source/VirtualDesktop/VirtualDesktop.csproj +++ b/source/VirtualDesktop/VirtualDesktop.csproj @@ -52,9 +52,12 @@ + + + + -