Skip to content

Commit 70e2c72

Browse files
br-skfilmor
authored andcommitted
Fix parameter passing for .NET Framework domains
1 parent 000bc78 commit 70e2c72

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Diff for: clr_loader/netfx.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ def __init__(
1414
):
1515
initialize()
1616
if config_file is not None:
17-
config_file_s = str(config_file)
17+
config_file_s = str(config_file).encode("utf8")
1818
else:
1919
config_file_s = ffi.NULL
2020

21+
domain_s = domain.encode("utf8") if domain else ffi.NULL
22+
2123
self._domain_name = domain
2224
self._config_file = config_file
23-
self._domain = _FW.pyclr_create_appdomain(domain or ffi.NULL, config_file_s)
25+
self._domain = _FW.pyclr_create_appdomain(domain_s, config_file_s)
2426

2527
def info(self) -> RuntimeInfo:
2628
return RuntimeInfo(
@@ -41,6 +43,11 @@ def _get_callable(self, assembly_path: StrOrPath, typename: str, function: str):
4143
function.encode("utf8"),
4244
)
4345

46+
if func == ffi.NULL:
47+
raise RuntimeError(
48+
f"Failed to resolve {typename}.{function} from {assembly_path}"
49+
)
50+
4451
return func
4552

4653
def shutdown(self):

Diff for: netfx_loader/ClrLoader.cs

+2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ public static IntPtr CreateAppDomain(
3232
{
3333
var setup = new AppDomainSetup
3434
{
35+
ApplicationBase = AppDomain.CurrentDomain.BaseDirectory,
3536
ConfigurationFile = configFile
3637
};
38+
Print($"Base: {AppDomain.CurrentDomain.BaseDirectory}");
3739
var domain = AppDomain.CreateDomain(name, null, setup);
3840

3941
Print($"Located domain {domain}");

0 commit comments

Comments
 (0)