Skip to content

Using a relocated Mono #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tkacvins opened this issue Sep 3, 2021 · 5 comments · Fixed by #43
Closed

Using a relocated Mono #27

tkacvins opened this issue Sep 3, 2021 · 5 comments · Fixed by #43

Comments

@tkacvins
Copy link

tkacvins commented Sep 3, 2021

Environment

  • Pythonnet version: 2.5.2
  • Python version: 3.9.2
  • Operating System: CentOS 7
  • .NET Runtime: 4.5

Details

  • I relocated the mono I built from source (in preparation for embedding mono in a product) and got this
The assembly mscorlib.dll was not found or could not be loaded.
It should have been installed in the `/opt/mono-6.8.0.123/lib/mono/4.5/mscorlib.dll' directory.

My understanding is mono can be relocated, but it requires invoking their C API to set the assembly paths, etc...
It would be nice if clr-loader could enable this by calling the right functions from libmono-2.so

I found this problem after relocating mono by running

echo "import clr" | python3

@tkacvins
Copy link
Author

tkacvins commented Sep 4, 2021

This web page

https://www.mono-project.com/docs/advanced/embedding/

describe the C API functions from mono that would need to be called to allow use of a relocatable mono.

@filmor
Copy link
Member

filmor commented Sep 9, 2021

Contributions are welcome. The project that does the loading of libmono is https://github.com/pythonnet/clr-loader. The loading is implemented in https://github.com/pythonnet/clr-loader/blob/master/clr_loader/mono.py, if you need additional API functions you can add their signature in https://github.com/pythonnet/clr-loader/blob/master/clr_loader/ffi/mono.py.

@tkacvins
Copy link
Author

OK, I will endeavor to do this. I am wondering if setting an environment variable to the relocated mono is the way to go. If that environment variable is set, call the mono C API routines for setting up mono for its new location, and if not, don't call those routines

@filmor filmor transferred this issue from pythonnet/pythonnet Jul 8, 2022
@filmor filmor changed the title Feature request - allowing Python.NET to used a relocated mono Using a relocated Mono Sep 16, 2022
@filmor
Copy link
Member

filmor commented Sep 16, 2022

If I see this correctly, this is really just a matter of calling mono_set_dirs.

@tkacvins
Copy link
Author

Agreed, I had determined that using mono_set_dirs is what I want to use, but I never had a chance to roll back around to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants