[Mono-list] DllNotFoundException

colin at breame.net colin at breame.net
Mon Mar 12 10:23:55 EDT 2007


I'm having problems getting my old nsqlcli project
(http://nsqlcli.sf.net) running on the latest mono release.

Using the DllImport attribute to import 'readline' out of libreadline I
get a DllNotFoundException.  This is what I do:

 $ gmcs test.cs  # see below
 $ mono test.exe
    Unhandled Exception: System.DllNotFoundException: libreadline.so.4
      at (wrapper managed-to-native) readline_t:readline (string)
      at readline_t.Main () [0x00000]
 $ /sbin/ldconfig -p | grep libreadline
    libreadline.so.4 (libc6) => /usr/lib/libreadline.so.4
 $ ls -l /usr/lib/libreadline.so.4
    lrwxrwxrwx  1 root root 18 Aug 30  2006 /usr/lib/libreadline.so.4 ->
    libreadline.so.4.3
 $ ls -l /usr/lib/libreadline.so.4.3
    -rwxr-xr-x  1 root root 170236 Feb 21  2005
    /usr/lib/libreadline.so.4.3

I've tried setting name (in test.cs) to "libreadline.so.4.3" and
"libreadline.so" but I get the same result.

My question is; what other things can go wrong loading a library that
can cause a DllNotFoundException using DllImport?

Thanks
C.

test.cs:
public class readline_t {
  const string name = "libreadline.so.4";
  public static void Main() {
    System.Console.WriteLine(readline("> "));
  }
  [System.Runtime.InteropServices.DllImport(name)]
  extern public static string readline(string prompt);
}


More information about the Mono-list mailing list