10000 Added inline comment about dangers of multidomain usage · pythonnet/pythonnet@9ba5be5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9ba5be5

Browse files
JanKrivanekfilmor
authored andcommitted
Added inline comment about dangers of multidomain usage
As requested here: #538 (comment)
1 parent 6488c2a commit 9ba5be5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/runtime/assemblymanager.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ internal class AssemblyManager
1717
{
1818
// modified from event handlers below, potentially triggered from different .NET threads
1919
// therefore this should be a ConcurrentDictionary
20+
//
21+
// WARNING: Dangerous if cross-app domain usage is ever supported
22+
// Reusing the dictionary with assemblies accross multiple initializations is problematic.
23+
// Loading happens from CurrentDomain (see line 53). And if the first call is from AppDomain that is later unloaded,
24+
// than it can end up referring to assemblies that are already unloaded (default behavior after unload appDomain -
25+
// unless LoaderOptimization.MultiDomain is used);
26+
// So for multidomain support it is better to have the dict. recreated for each app-domain initialization
2027
private static ConcurrentDictionary<string, ConcurrentDictionary<Assembly, string>> namespaces =
2128
new ConcurrentDictionary<string, ConcurrentDictionary<Assembly, string>>();
2229
//private static Dictionary<string, Dictionary<string, string>> generics;

0 commit comments

Comments
 (0)
0