[Mono-list] System.DllNotFoundException
Martin Welch
martin@welch.eclipse.co.uk
Thu, 8 Apr 2004 23:25:35 +0100
This is a multi-part message in MIME format.
------=_NextPart_000_0011_01C41DC0.CB8DA300
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
I'm making progress.
My library foo.so comprises two cpp files that only contain extern "C"
functions.
If i build this library and PInvoke to it everything's ok.
If I then add another cpp file, this time with a class definition and
implementation then I get the System.DllNotFoundException, even if the class
isn't referenced by the extern "C" functions.
Take the cpp file out and it works again.
Is this making sense? What am I doing wrong?
Thanks,
Martin
-----Original Message-----
From: mono-list-admin@lists.ximian.com
[mailto:mono-list-admin@lists.ximian.com]On Behalf Of Martin Welch
Sent: 08 April 2004 19:40
To: Mono-List
Subject: [Mono-list] System.DllNotFoundException
I have a simple c# app trying to PInvoke to a shared library on my
Mandrake 10 box using Mono-0.31.
I assumed that mono would look in the current directory but it seems my
assumption is wrong since the so in question does exist.
I'm even hardcoding the path in my DllImport attribute:
[
DllImport
(
"/home/martin/source/foo",
EntryPoint="MyFunc",
CharSet=CharSet.Ansi,
CallingConvention=CallingConvention.Cdecl
)
]
private static extern IntPtr MyFunc(int v,
[MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr)]
string[] a, string n);
Please bear in mind that I'm not a very experienced linux user so in all
likelihood I've done something profoundly stupid or overlooked something
really obvious.
Where does mono look for so's?
Thanks,
Martin
------=_NextPart_000_0011_01C41DC0.CB8DA300
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR></HEAD>
<BODY>
<DIV><FONT face=3DVerdana color=3D#0000ff size=3D2><SPAN =
class=3D498461922-08042004>I'm=20
making progress.</SPAN></FONT></DIV>
<DIV><FONT face=3DVerdana color=3D#0000ff size=3D2><SPAN=20
class=3D498461922-08042004></SPAN></FONT> </DIV>
<DIV><FONT face=3DVerdana color=3D#0000ff size=3D2><SPAN =
class=3D498461922-08042004>My=20
library foo.so comprises two cpp files that only contain extern "C"=20
functions.</SPAN></FONT></DIV>
<DIV><FONT face=3DVerdana color=3D#0000ff size=3D2><SPAN=20
class=3D498461922-08042004></SPAN></FONT> </DIV>
<DIV><FONT face=3DVerdana color=3D#0000ff size=3D2><SPAN =
class=3D498461922-08042004>If i=20
build this library and PInvoke to it everything's =
ok.</SPAN></FONT></DIV>
<DIV><FONT face=3DVerdana color=3D#0000ff size=3D2><SPAN=20
class=3D498461922-08042004></SPAN></FONT> </DIV>
<DIV><FONT face=3DVerdana color=3D#0000ff size=3D2><SPAN =
class=3D498461922-08042004>If I=20
then add another cpp file, this time with a class definition and =
implementation=20
then I get the System.DllNotFoundException, even if the class isn't =
referenced=20
by the extern "C" functions.</SPAN></FONT></DIV>
<DIV><FONT face=3DVerdana color=3D#0000ff size=3D2><SPAN=20
class=3D498461922-08042004></SPAN></FONT> </DIV>
<DIV><FONT face=3DVerdana color=3D#0000ff size=3D2><SPAN =
class=3D498461922-08042004>Take=20
the cpp file out and it works again.</SPAN></FONT></DIV>
<DIV><FONT face=3DVerdana color=3D#0000ff size=3D2><SPAN=20
class=3D498461922-08042004></SPAN></FONT> </DIV>
<DIV><FONT face=3DVerdana color=3D#0000ff size=3D2><SPAN =
class=3D498461922-08042004>Is=20
this making sense? What am I doing wrong?</SPAN></FONT></DIV>
<DIV><FONT face=3DVerdana color=3D#0000ff size=3D2><SPAN=20
class=3D498461922-08042004></SPAN></FONT> </DIV>
<DIV><FONT face=3DVerdana color=3D#0000ff size=3D2><SPAN=20
class=3D498461922-08042004>Thanks,</SPAN></FONT></DIV>
<DIV><FONT face=3DVerdana color=3D#0000ff size=3D2><SPAN=20
class=3D498461922-08042004></SPAN></FONT> </DIV>
<DIV><FONT face=3DVerdana color=3D#0000ff size=3D2><SPAN=20
class=3D498461922-08042004>Martin</SPAN></FONT></DIV>
<BLOCKQUOTE dir=3Dltr style=3D"MARGIN-RIGHT: 0px">
<DIV class=3DOutlookMessageHeader dir=3Dltr align=3Dleft><FONT =
face=3DTahoma=20
size=3D2>-----Original Message-----<BR><B>From:</B>=20
mono-list-admin@lists.ximian.com=20
[mailto:mono-list-admin@lists.ximian.com]<B>On Behalf Of </B>Martin=20
Welch<BR><B>Sent:</B> 08 April 2004 19:40<BR><B>To:</B>=20
Mono-List<BR><B>Subject:</B> [Mono-list]=20
System.DllNotFoundException<BR><BR></FONT></DIV>
<DIV><FONT face=3DVerdana size=3D2><SPAN class=3D128442718-08042004>I =
have a simple=20
c# app trying to PInvoke to a shared library on my Mandrake 10 box =
using=20
Mono-0.31.</SPAN></FONT></DIV>
<DIV><FONT face=3DVerdana size=3D2><SPAN=20
class=3D128442718-08042004></SPAN></FONT> </DIV>
<DIV><FONT face=3DVerdana size=3D2><SPAN class=3D128442718-08042004>I =
assumed that=20
mono would look in the current directory but it seems my assumption is =
wrong=20
since the so in question does exist.</SPAN></FONT></DIV>
<DIV><FONT face=3DVerdana size=3D2><SPAN=20
class=3D128442718-08042004></SPAN></FONT> </DIV>
<DIV><FONT face=3DVerdana size=3D2><SPAN =
class=3D128442718-08042004>I'm even=20
hardcoding the path in my DllImport attribute:</SPAN></FONT></DIV>
<DIV><FONT face=3DVerdana size=3D2><SPAN=20
class=3D128442718-08042004></SPAN></FONT> </DIV>
<DIV><FONT face=3DVerdana size=3D2><SPAN=20
=
class=3D128442718-08042004> [<BR> DllImport<BR>&nbs=
p; (<BR> "/home/martin/source/foo",=20
<BR> EntryPoint=3D"MyFunc", =
<BR> CharSet=3DCharSet.Ansi,=20
=
<BR> CallingConvention=3DCallingConvention.Cdecl<BR> &nbs=
p;)<BR> ]<BR> private=20
static extern IntPtr MyFunc(int v, [MarshalAs(UnmanagedType.LPArray,=20
ArraySubType=3DUnmanagedType.LPStr)] string[] a, string=20
n);<BR></SPAN></FONT></DIV>
<DIV><FONT face=3DVerdana size=3D2><SPAN =
class=3D128442718-08042004>Please bear in=20
mind that I'm not a very experienced linux user so in all likelihood =
I've done=20
something profoundly stupid or overlooked something really=20
obvious.</SPAN></FONT></DIV>
<DIV><FONT face=3DVerdana size=3D2><SPAN=20
class=3D128442718-08042004></SPAN></FONT> </DIV>
<DIV><FONT face=3DVerdana size=3D2><SPAN =
class=3D128442718-08042004><SPAN=20
class=3D128442718-08042004>Where does mono look for so's?=20
</SPAN></SPAN></FONT></DIV>
<DIV><FONT face=3DVerdana size=3D2><SPAN =
class=3D128442718-08042004><SPAN=20
class=3D128442718-08042004></SPAN></SPAN></FONT> </DIV>
<DIV><FONT face=3DVerdana size=3D2><SPAN =
class=3D128442718-08042004><SPAN=20
class=3D128442718-08042004>Thanks,</SPAN></SPAN></FONT></DIV>
<DIV><FONT face=3DVerdana size=3D2><SPAN =
class=3D128442718-08042004><SPAN=20
class=3D128442718-08042004></SPAN></SPAN></FONT> </DIV>
<DIV><FONT face=3DVerdana size=3D2><SPAN =
class=3D128442718-08042004><SPAN=20
=
class=3D128442718-08042004>Martin</SPAN></DIV></BLOCKQUOTE></SPAN></FONT>=
</BODY></HTML>
------=_NextPart_000_0011_01C41DC0.CB8DA300--