Skip to content

Commit c3445ff

Browse files
authored
Added extra info about error when hostfxr not found or loaded properly. (#76)
#75
1 parent 5dadf4c commit c3445ff

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

clr_loader/ffi/__init__.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,20 @@ def load_hostfxr(dotnet_root: Path):
2323
hostfxr_path = dotnet_root / "host" / "fxr"
2424
hostfxr_paths = hostfxr_path.glob(f"?.*/{hostfxr_name}")
2525

26+
error_report = list()
27+
2628
for hostfxr_path in reversed(sorted(hostfxr_paths, key=_path_to_version)):
2729
try:
2830
return ffi.dlopen(str(hostfxr_path))
29-
except Exception:
30-
pass
31+
except Exception as err:
32+
error_report.append(f"Path {hostfxr_path} gave the following error:\n{err}")
3133

3234
try:
3335
return ffi.dlopen(str(dotnet_root / hostfxr_name))
34-
except Exception:
35-
pass
36+
except Exception as err:
37+
error_report.append(f"Path {hostfxr_path} gave the following error:\n{err}")
3638

37-
raise RuntimeError(f"Could not find a suitable hostfxr library in {dotnet_root}")
39+
raise RuntimeError(f"Could not find a suitable hostfxr library in {dotnet_root}. The following paths were scanned:\n\n"+("\n\n".join(error_report)))
3840

3941

4042
def load_mono(path: Optional[Path] = None):

0 commit comments

Comments
 (0)