Skip to content

Commit 677281e

Browse files
JanKrivanekfilmor
authored andcommitted
Added inline comment about dangers of multidomain usage
As requested here: #538 (comment)
1 parent 8a9fd73 commit 677281e

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

AUTHORS.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
- Dmitriy Se ([@dmitriyse](https://github.com/dmitriyse))
2727
- He-chien Tsai ([@t3476](https://github.com/t3476))
2828
-   Ivan Cronyn ([@cronan](https://github.com/cronan))
29+
- Jan Krivanek ([@jakrivan](https://github.com/jakrivan))
2930
-   Jeff Reback ([@jreback](https://github.com/jreback))
3031
- Joe Frayne ([@jfrayne](https://github.com/jfrayne))
3132
- John Burnett ([@johnburnett](https://github.com/johnburnett))

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
1919
- Catches exceptions thrown in C# iterators (yield returns) and rethrows them in python ([#475][i475])([#693][p693])
2020
- Implemented GetDynamicMemberNames() for PyObject to allow dynamic object members to be visible in the debugger ([#443][i443])([#690][p690])
2121
- Incorporated reference-style links to issues and pull requests in the CHANGELOG ([#608][i608])
22+
- Added detailed comments about aproaches and dangers to handle multi-app-domains ([#625][p625])
2223

2324
### Changed
2425

@@ -683,4 +684,5 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
683684
[p225]: https://github.com/pythonnet/pythonnet/pull/225
684685
[p78]: https://github.com/pythonnet/pythonnet/pull/78
685686
[p163]: https://github.com/pythonnet/pythonnet/pull/163
687+
[p625]: https://github.com/pythonnet/pythonnet/pull/625
686688
[i131]: https://github.com/pythonnet/pythonnet/issues/131

src/runtime/assemblymanager.cs

+8
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ 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;
28+
2129
//private static Dictionary<string, Dictionary<string, string>> generics;
2230
private static AssemblyLoadEventHandler lhandler;
2331
private static ResolveEventHandler rhandler;

0 commit comments

Comments
 (0)