| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent dfdcfe7 commit b65fa30
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,6 +30,7 @@ internal class AssemblyManager { | |||
| 30 | 30 | static ResolveEventHandler rhandler; | |
| 31 | 31 | static Dictionary<string, int> probed; | |
| 32 | 32 | static List<Assembly> assemblies; | |
| 33 | + static Dictionary<string, Assembly> loadedAssemblies; | ||
| 33 | 34 | internal static List<string> pypath; | |
| 34 | 35 | ||
| 35 | 36 | private AssemblyManager() {} | |
@@ -46,6 +47,7 @@ internal static void Initialize() { | |||
| 46 | 47 | probed = new Dictionary<string, int>(32); | |
| 47 | 48 | //generics = new Dictionary<string, Dictionary<string, string>>(); | |
| 48 | 49 | assemblies = new List<Assembly>(16); | |
| 50 | + loadedAssemblies = new Dictionary<string, Assembly>(); | ||
| 49 | 51 | pypath = new List<string>(16); | |
| 50 | 52 | ||
| 51 | 53 | AppDomain domain = AppDomain.CurrentDomain; | |
@@ -202,7 +204,19 @@ public static Assembly LoadAssemblyPath(string name) { | |||
| 202 | 204 | string path = FindAssembly(name); | |
| 203 | 205 | Assembly assembly = null; | |
| 204 | 206 | if (path != null) { | |
| 205 | - try { assembly = Assembly.LoadFrom(path); } | ||
| 207 | + if (loadedAssemblies.ContainsKey(path)) { | ||
| 208 | + return loadedAssemblies[path]; | ||
| 209 | + } | ||
| 210 | + // Avoid using Assembly.LoadFrom as referenced assemblies that exist | ||
| 211 | + // in the same path will be loaded directly from there, rather than | ||
| 212 | + // using other versions already loaded. This is a problem if there | ||
| 213 | + // is a Python.Runtime.dll in the same folder as the assembly being | ||
| 214 | + // loaded, as that will result in two instances being loaded. | ||
| 215 | + try { | ||
| 216 | + byte[] bytes = System.IO.File.ReadAllBytes(path); | ||
| 217 | + assembly = Assembly.Load(bytes); | ||
| 218 | + loadedAssemblies[path] = assembly; | ||
| 219 | + } | ||
| 206 | 220 | catch {} | |
| 207 | 221 | } | |
| 208 | 222 | return assembly; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments