@@ -29,6 +29,10 @@ public sealed class EditorServicesLoader : IDisposable
29
29
{
30
30
private const int Net461Version = 394254 ;
31
31
32
+ #if ! CoreCLR
33
+ private static readonly string s_psesBaseDirPath = Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ;
34
+ #endif
35
+
32
36
private static readonly string s_psesDependencyDirPath = Path . GetFullPath (
33
37
Path . Combine (
34
38
Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ,
@@ -72,7 +76,6 @@ public static EditorServicesLoader Create(
72
76
73
77
#if CoreCLR
74
78
// In .NET Core, we add an event here to redirect dependency loading to the new AssemblyLoadContext we load PSES' dependencies into
75
-
76
79
logger . Log ( PsesLogLevel . Verbose , "Adding AssemblyResolve event handler for new AssemblyLoadContext dependency loading" ) ;
77
80
78
81
var psesLoadContext = new PsesLoadContext ( s_psesDependencyDirPath ) ;
@@ -123,14 +126,25 @@ public static EditorServicesLoader Create(
123
126
logger . Log ( PsesLogLevel . Diagnostic , $ "Assembly resolve event fired for { args . Name } ") ;
124
127
125
128
var asmName = new AssemblyName ( args . Name ) ;
126
- string asmPath = Path . Combine ( s_psesDependencyDirPath , $ "{ asmName . Name } .dll") ;
127
- if ( ! File . Exists ( asmPath ) )
129
+ var dllName = $ "{ asmName . Name } .dll";
130
+
131
+ // First look for the required assembly in the .NET Framework DLL dir
132
+ string baseDirAsmPath = Path . Combine ( s_psesBaseDirPath , dllName ) ;
133
+ if ( File . Exists ( baseDirAsmPath ) )
128
134
{
129
- return null ;
135
+ logger . Log ( PsesLogLevel . Diagnostic , $ "Loading { args . Name } from PSES base dir into LoadFrom context") ;
136
+ return Assembly . LoadFrom ( baseDirAsmPath ) ;
137
+ }
138
+
139
+ // Then look in the shared .NET Standard directory
140
+ string asmPath = Path . Combine ( s_psesDependencyDirPath , dllName ) ;
141
+ if ( File . Exists ( asmPath ) )
142
+ {
143
+ logger . Log ( PsesLogLevel . Diagnostic , $ "Loading { args . Name } from PSES dependency dir into LoadFrom context") ;
144
+ return Assembly . LoadFrom ( asmPath ) ;
130
145
}
131
146
132
- logger . Log ( PsesLogLevel . Diagnostic , $ "Loading { args . Name } from PSES dependency dir into LoadFrom context") ;
133
- return Assembly . LoadFrom ( asmPath ) ;
147
+ return null ;
134
148
} ;
135
149
#endif
136
150
0 commit comments