Commit 5dadf4c
Support pythonnet for AppDomain (#78)
* load the assembly and get function address inside the domain
When using domain.Load for an assembly, the assembly resolution rules are awkward
Even if the full path is given to the AssemblyName, when the domain tries to load
the assembly, it does not use that context and tries to resolve the assembly using
normal domain resolution rules, which would require an assembly resolver to be
installed. However, the assembly resolver that is actually used at runtime is the
one installed to the main appdomain.
This prevents a library like Python.Runtime.dll (used by pythonnet) which
is not installed to the application base directory to be loaded by clr_loader.
To fix this issue, the assembly resolver of the main appdomain is lazily
extending to include paths needed for libraries passed into GetFunction,
and GetFunction internally uses AppDomain.DoCallBack() to marshal the
function pointer inside the target app domain, using global domain data
to access the function pointer and return it to the user of clr_loader.
* Add comment
* PR review feedback
---------
Co-authored-by: Mohamed Koubaa <[email protected]>1 parent f9e0544 commit 5dadf4c
2 files changed
+100
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
24 | 38 | | |
25 | 39 | | |
26 | 40 | | |
27 | 41 | | |
28 | 42 | | |
29 | 43 | | |
30 | 44 | | |
| 45 | + | |
| 46 | + | |
31 | 47 | | |
32 | 48 | | |
33 | 49 | | |
34 | 50 | | |
35 | | - | |
| 51 | + | |
36 | 52 | | |
37 | 53 | | |
38 | | - | |
| 54 | + | |
39 | 55 | | |
40 | | - | |
41 | 56 | | |
42 | 57 | | |
43 | 58 | | |
| |||
61 | 76 | | |
62 | 77 | | |
63 | 78 | | |
64 | | - | |
65 | | - | |
| 79 | + | |
| 80 | + | |
66 | 81 | | |
67 | 82 | | |
68 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | | - | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
13 | 38 | | |
14 | 39 | | |
15 | 40 | | |
16 | | - | |
| 41 | + | |
| 42 | + | |
17 | 43 | | |
18 | 44 | | |
19 | 45 | | |
20 | 46 | | |
21 | | - | |
| 47 | + | |
| 48 | + | |
22 | 49 | | |
23 | 50 | | |
24 | | - | |
| 51 | + | |
25 | 52 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
32 | 57 | | |
33 | | - | |
| 58 | + | |
34 | 59 | | |
35 | | - | |
36 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
37 | 65 | | |
38 | | - | |
39 | | - | |
| 66 | + | |
40 | 67 | | |
41 | | - | |
42 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
43 | 72 | | |
44 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
45 | 106 | | |
46 | 107 | | |
47 | 108 | | |
48 | 109 | | |
49 | 110 | | |
50 | 111 | | |
51 | | - | |
| 112 | + | |
52 | 113 | | |
53 | 114 | | |
54 | 115 | | |
| |||
0 commit comments