[Mono-list] Unhandled Exception: System.DllNotFoundException: db2_36
Bartolomeo Nicolotti
bnicolotti at siapcn.it
Wed Feb 11 04:36:52 EST 2009
Bartolomeo Nicolotti wrote:
>
> Hello,
>
> I've installed mono, and xsp (not yet mod_mono) on ubuntu following the
> instruction here:
>
> http://ubuntuforums.org/showthread.php?t=803743
>
> in view of using mod_mono together with php on ubuntu server 8.04, to
> migrate a web service that access a db2/as400 database.
>
> I've also installed db2exc from ubuntu repository as said here:
>
> http://www.ubuntu.com/partners/ibm/db2
>
> I can compile a test program that does a query to the db:
>
> siap at LxPC54:~/src/test$ gmcs -r:/usr/lib/mono/1.0/IBM.Data.DB2.dll
> -r:/usr/lib/mono/2.0/System.Data.dll helloDB2.cs
>
> but when I execute it:
>
> siap at LxPC54:~/src/test$ mono helloDB2.exe bart
> Hello, bart
>
> Unhandled Exception: System.DllNotFoundException: db2_36
> at (wrapper managed-to-native)
> IBM.Data.DB2.DB2CLIWrapper/StaticWrapper36:SQLAllocHandle
> (int16,intptr,intptr&)
> at IBM.Data.DB2.DB2CLIWrapper.SQLAllocHandle (Int16 handleType, IntPtr
> inputHandle, System.IntPtr& outputHandle) [0x00000]
> at IBM.Data.DB2.DB2CLIWrapper.Initialize (System.IntPtr& pEnvHandle)
> [0x00000]
> at IBM.Data.DB2.DB2Environment..ctor () [0x00000]
> at IBM.Data.DB2.DB2Environment.get_Instance () [0x00000]
> at IBM.Data.DB2.DB2ConnectionPool.FindConnectionPool (System.String
> connectionString) [0x00000]
> at IBM.Data.DB2.DB2ConnectionSettings.GetConnectionSettings
> (System.String connectionString) [0x00000]
> at IBM.Data.DB2.DB2Connection.SetConnectionString (System.String
> connectionString) [0x00000]
> at IBM.Data.DB2.DB2Connection..ctor (System.String conString) [0x00000]
> at (wrapper remoting-invoke-with-check) IBM.Data.DB2.DB2Connection:.ctor
> (string)
> at HelloWorldDb2.Main (System.String[] args) [0x00000]
>
> I've tried to edit /etc/mono/config:
>
> sudo vim /etc/mono/config
>
> <dllmap dll="oci" target="libclntsh.so" os="!windows"/>
> <dllmap dll="db2cli" target="libdb2_36.so" os="!windows"/>
>
> adding this line:
>
> <dllmap dll="db2_36" target="libdb2.so" os="!windows"/>
>
> and executed this command:
>
> sudo /sbin/ldconfig /opt/ibm/db2exc/V9.5/lib32
>
> this because the right lib should be:
>
> /sbin/ldconfig /opt/ibm/db2exc/V9.5/lib32/libdb2.so
>
> as below http://www.nabble.com/file/p21950856/helloDB2.cs helloDB2.cs
>
> siap at LxPC54:~/src/mono/mono-2.2/mcs/class/IBM.Data.DB2/IBM.Data.DB2$ vim
> DB2CLIWrapper.cs
>
>
> public class StaticWrapper36
> {
> private const string libname = "db2_36";
>
> [DllImport(libname, EntryPoint =
> "SQLAllocHandle")]
> public static extern short SQLAllocHandle(short
> handleType, IntPtr inputHandle, out IntPtr outputHandle);
> [DllImport(libname, EntryPoint = "SQLFreeHandle")]
> public static extern short SQLFreeHandle(short
> handleType, IntPtr inputHandle);
>
> ....
>
> siap at LxPC54:/usr/local/lib/xsp/test$ nm
> /opt/ibm/db2exc/V9.5/lib32/libdb2.so.1 | grep SQLAllocHandle
> 001dadd4 T SQLAllocHandle
> 00d28bec d SQLAllocHandle$$LSDA
>
> 00d2d260 d SQLGetDiagRecW$$LSDA
> 002716d8 T
> _Z14SQLGetDiagRec2P19CLI_ERRORHEADERINFOiPhPiS1_sPshhP17CLI_STATEMENTINFO
> 00d2ae78 d
> _Z14SQLGetDiagRec2P19CLI_ERRORHEADERINFOiPhPiS1_sPshhP17CLI_STATEMENTINFO$$LSDA
>
Following this
http://www.mono-project.com/DllNotFoundException
i've checked that Imodified the wrong file:
i did
sudo vim /etc/mono/config
but the right file is:
sudo vim /usr/local/etc/mono/config
now it works (the error is a missing conn.Open())!!
siap at LxPC54:~/src/test$ mono helloDB2.exe bart > mono_debug.txt
Unhandled Exception: System.InvalidOperationException: Prepare needs an open
connection
at IBM.Data.DB2.DB2Command.ExecuteReader (CommandBehavior behavior)
[0x00000]
at IBM.Data.DB2.DB2Command.ExecuteReader () [0x00000]
at (wrapper remoting-invoke-with-check)
IBM.Data.DB2.DB2Command:ExecuteReader ()
at HelloWorldDb2.Main (System.String[] args) [0x00000]
--
View this message in context: http://www.nabble.com/Unhandled-Exception%3A-System.DllNotFoundException%3A-db2_36-tp21950856p21951210.html
Sent from the Mono - General mailing list archive at Nabble.com.
More information about the Mono-list
mailing list