[Mono-bugs] [Bug 471862] System.DllNotFoundException

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Feb 3 23:07:25 EST 2009


https://bugzilla.novell.com/show_bug.cgi?id=471862

User csvadiraj at novell.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=471862#c5


vadiraj c s <csvadiraj at novell.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |




--- Comment #5 from vadiraj c s <csvadiraj at novell.com>  2009-02-03 21:07:23 MST ---
I'm using the mono that comes with distro not the one we compile.


On ppc64.

# file /usr/lib64/librpm.so
/usr/lib64/librpm.so: symbolic link to `librpm-4.4.so'
:~/progs # file /usr/lib64/librpm-4.4.so 
/usr/lib64/librpm-4.4.so: ELF 64-bit MSB shared object, 64-bit PowerPC or cisco
7500, version 1 (SYSV), dynamically linked, stripped
~/progs #  LD_LIBRARY_PATH=$LIBRARY_PATH:/usr/lib64 MONO_LOG_LEVEL="debug"
MONO_LOG_MASK="dll" mono DllImp.exe 
Mono-INFO: DllImport attempting to load: 'librpm'.
Mono-INFO: DllImport loading location: 'librpm.so'.
Mono-INFO: DllImport error loading library: 'librpm.so: wrong ELF class:
ELFCLASS64'.
Mono-INFO: DllImport loading library: './librpm.so'.
Mono-INFO: DllImport error loading library './librpm.so: cannot open shared
object file: No such file or directory'.
Mono-INFO: DllImport loading: 'librpm'.
Mono-INFO: DllImport error loading library 'librpm: cannot open shared object
file: No such file or directory'.

(DllImp.exe:9519): Mono-WARNING **: DllImport unable to load library 'librpm:
cannot open shared object file: No such file or directory'.
Mono-INFO: DllImport attempting to load: 'librpm'.
Mono-INFO: DllImport loading location: 'librpm.so'.
Mono-INFO: DllImport error loading library: 'librpm.so: wrong ELF class:
ELFCLASS64'.
Mono-INFO: DllImport loading library: './librpm.so'.
Mono-INFO: DllImport error loading library './librpm.so: cannot open shared
object file: No such file or directory'.
Mono-INFO: DllImport loading: 'librpm'.
Mono-INFO: DllImport error loading library 'librpm: cannot open shared object
file: No such file or directory'.

(DllImp.exe:9519): Mono-WARNING **: DllImport unable to load library 'librpm:
cannot open shared object file: No such file or directory'.

Unhandled Exception: System.DllNotFoundException: librpm
  at (wrapper managed-to-native) DllImp:rpmvercmp (string,string)
  at DllImp.Main () [0x00000] 



2 things to observe.
1. Though ldconfig -p does display the librpm, it failed to find the library.
2. Ran it after exporting LD_LIBRARY_PATH, gave 'librpm.so: wrong ELF class:
ELFCLASS64'.

I tried linking the library through a C file to see if wrong ELF class is valid
one.

C program linked and ran successfully.


#include <stdio.h>
int rpmvercmp (char* a, char* b);



int main()
{
        printf("%d\n",rpmvercmp("gcc","gcc") );
}

:~/progs # gcc DllImport.c -lrpm -o DllImport
:~/progs # ./DllImport
0

This is evident that there is no problem with library. And also ran the same
program on 32bit platform. Runs successfully. So test case is also valid.
Output of 32bit execution below.

On 32bit platform


#file /usr/lib/librpm.so
/usr/lib/librpm.so: symbolic link to `librpm-4.4.so'
#~/progs> file /usr/lib/librpm-4.4.so 
/usr/lib/librpm-4.4.so: ELF 32-bit LSB shared object, Intel 80386, version 1
(SYSV), stripped
#~/progs> MONO_LOG_LEVEL="debug" MONO_LOG_MASK="dll" mono DllImp.exe
Mono-INFO: DllImport attempting to load: 'librpm'.
Mono-INFO: DllImport loading location: 'librpm.so'.
Mono-INFO: Searching for 'rpmvercmp'.
Mono-INFO: Probing 'rpmvercmp'.
Mono-INFO: Found as 'rpmvercmp'.



And one more point to say that test case is valid, same program when linked to
libc.so succeeds.


:~/progs# cat dllImp.cs
using System;
using System.Runtime.InteropServices;
using System.Collections;
using System.Threading;
public class dllImp
{
        [DllImport ("libc")]
        extern static int system (string command);

    public static void Main()
    {
        system("ls -l > /tmp/ls.txt") ;
    }
}

hurtleberry:~/progs # mcs dllImp.cs
hurtleberry:~/progs # mono dllImp.exe
hurtleberry:~/progs # cat /tmp/ls.txt
total 52
-rw-r--r-- 1 root root   276 2009-02-04 04:55 dllImp.cs
-rw-r--r-- 1 root root   278 2009-02-03 10:18 DllImp.cs
-rwxr-xr-x 1 root root  3072 2009-02-04 04:55 dllImp.exe
-rwxr-xr-x 1 root root  3072 2009-02-03 10:19 DllImp.exe
-rwxr-xr-x 1 root root 12810 2009-02-04 04:46 DllImport
-rw-r--r-- 1 root root   112 2009-02-04 04:46 DllImport.c
-rwxr-xr-x 1 root root 12752 2009-02-04 04:45 DllImport.o

hurtleberry:~/progs # MONO_LOG_LEVEL="debug" MONO_LOG_MASK="dll" mono
dllImp.exe 
Mono-INFO: DllImport attempting to load: 'libc.so.6'.
Mono-INFO: DllImport loading location: 'libc.so.6.so'.
Mono-INFO: DllImport error loading library: 'libc.so.6.so: cannot open shared
object file: No such file or directory'.
Mono-INFO: DllImport loading library: './libc.so.6.so'.
Mono-INFO: DllImport error loading library './libc.so.6.so: cannot open shared
object file: No such file or directory'.
Mono-INFO: DllImport loading: 'libc.so.6'.
Mono-INFO: Searching for 'system'.
Mono-INFO: Probing 'system'.
Mono-INFO: Found as 'system'.

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list