Skip to content

Commit d09fc92

Browse files
author
dse
committed
Assembly loading experience improved + fixes.
1 parent 8ee0c65 commit d09fc92

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/runtime/assemblymanager.cs

+14-3
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,10 @@ public static Assembly LoadAssembly(string name)
203203
}
204204

205205
PythonEngine.RaiseAssemblyAsModuleImportingEvent(importEvent);
206-
207-
assembly = Assembly.Load(name);
206+
if (!importEvent.SkipAssemblyLoad)
207+
{
208+
assembly = Assembly.Load(name);
209+
}
208210
}
209211
catch (Exception)
210212
{
@@ -351,8 +353,17 @@ internal static void ScanAssembly(Assembly assembly)
351353
// A couple of things we want to do here: first, we want to
352354
// gather a list of all of the namespaces contributed to by
353355
// the assembly.
356+
Type[] types = new Type[0];
357+
try
358+
{
359+
types = assembly.IsDynamic ? assembly.GetTypes():assembly.GetExportedTypes();
360+
}
361+
catch(TypeLoadException)
362+
{
363+
// Do nothing.
364+
// This problem usually occurs when transitive dependencies have references to older packages than main application.
365+
}
354366

355-
Type[] types = assembly.GetTypes();
356367
foreach (Type t in types)
357368
{
358369
string ns = t.Namespace ?? "";

0 commit comments

Comments
 (0)