[Mono-list] DllImport and modifying library search path
Alexander M. Batishchev
abatishchev at godfather.net.ru
Fri Feb 11 03:12:10 EST 2011
Have you tried set the variable in static constructor? Or set probing
privatePath in App.config?
From: mono-list-bounces at lists.ximian.com
[mailto:mono-list-bounces at lists.ximian.com] On Behalf Of Uli Hertlein
Sent: Friday, February 11, 2011 10:26 AM
Subject: [Mono-list] DllImport and modifying library search path
I'm trying to come up with a way to transparently pick up the correct OS and
.dll/.so/.dylib from within my application.
Assume I have the following directory structure:
The DllImport only specifies the 'base' library name, i.e.
At runtime I assemble the directory based on Environment.Is64BitProcess and
Environment.OSVersion.Platform to end up with e.g. "Linux64" or "Win64".
Now, to pickup the correct shared library I thought I'd prefix the the
respective search path
(LD_LIBRARY_PATH on Linux, DYLD_LIBRARY_PATH on OS X, and PATH on Windows)
with this directory.
This is then set using
On Windows/CLR this works fine, but on Mono (Linux and Windows, mono-2.10
preview) it doesn't.
I've noticed (with MONO_LOG_LEVEL=debug) that Mono is trying to lookup the
DllImport before my main
even runs, as opposed to when the call to the lib is actually made.
So I am wondering if
- Mono is caching that first lookup (which fails, because the search path
isn't set properly)
- Mono makes a copy of the search path and hence doesn't notice later
changes to the environment
Or something else? Any ideas?
Research and Development mailto:uli at xdt.com.au
XDT Pty Ltd http://www.xdt.com.au
Mono-list maillist - Mono-list at lists.ximian.com
More information about the Mono-list