clr-loader icon indicating copy to clipboard operation
clr-loader copied to clipboard

Error loading clr into non-root domain

Open vadimkatsman opened this issue 2 years ago • 2 comments

Environment

  • Pythonnet version: 3.0.1
  • Python version: 3.10
  • Operating System: Windows Server 2019
  • .NET Runtime: .Net Framework 4.8

Details

  • Describe what you were trying to get done.

In order to configure a specific .Net configuration file, I had to run set_runtime prior of clr load.

import os
from pathlib import Path
config_file = r"...valid path...\sctlib.py.config"
config_path = Path(config_file)
from pythonnet import set_runtime
set_runtime("netfx", domain="sctlib_py", config_file=config_path)
#set_runtime("netfx", domain="sctlib_py")
import clr

The config file is valid as it is borrowed verbatim (with exception of renaming) from the working console application.

"import clr" statement never succeeded:

Same script running with default domain works without an issue (but of course, does not recognize the config file which I need to have to target proper .Net Framework)

  • If there was a crash, please include the traceback here.
Traceback (most recent call last):
  File "D:\_WorkRoot\Tests\Python_ASR\Diarization\_Examples\Enrichment\sctlib.py", line 9, in <module>
    import clr
  File "C:\Program Files\Python310\lib\site-packages\clr.py", line 6, in <module>
    load()
  File "C:\Program Files\Python310\lib\site-packages\pythonnet\__init__.py", line 143, in load
    if func(b"") != 0:
  File "C:\Program Files\Python310\lib\site-packages\clr_loader\types.py", line 64, in __call__
    return self._callable(ffi.cast("void*", buf_arr), len(buf_arr))
RuntimeError: cannot call null pointer pointer from cdata 'int(*)(void *, int)'

vadimkatsman avatar Feb 28 '23 19:02 vadimkatsman

I am aware of the issue of loading a separate domain and have not been able to fix it, yet. There is an open PR: #42

Help in debugging and furthering this is appreciated.

filmor avatar Mar 01 '23 13:03 filmor

It explains. I will make few comments if you don't mind to #42.

vadimkatsman avatar Mar 01 '23 15:03 vadimkatsman