tags:

views:

216

answers:

2
+1  Q: 

DLL Config in Mono

Hi,

I'm trying to pick up Svn.NET (http://www.pumacode.org/projects/svndotnet/) library for use in my Mono project. I tried compiling its mockapp -> svnmockapp project (http://www.pumacode.org/projects/svndotnet/browser/trunk/SvnMockApp) , I am able to get the references right and get it compiled right.

I understand that it references 2 other modules libapr (libapr-1.so.0) and svn_client (libsvn_client-1.so.0) , by which I've created PumaCode.SvnDotNet.dll.config in /bin/Debug .

That is all I've done to tried to try to get the mockapp at least outputting something to show that it is indeed interfacing SVN. Nevertheless, it is not working.

Commands that are entered that doesn't interface SVN works fine:

$ mono SvnTest.exe -usage
Usage: SvnTest <subcommand> [options]
Short Options: ~?.V
Subcommands: add, checkout[co], status[st], update[up]
For help on subcommands, use the -?/--help subcommand option.

Commands that tries to access SVN throws an exception:

$ mono SvnTest.exe st
An exception was thrown by the type initializer for PumaCode.SvnDotNet.AprSharp.Apr

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object
  at PumaCode.SvnDotNet.SubversionSharp.SvnMockApp.CmdBase.Run (PumaCode.SvnDotNet.SubversionSharp.SvnMockApp.SubCommand sc, System.String[] args) [0x00000]
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000]
  --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000]
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000]
  at PumaCode.SvnDotNet.SubversionSharp.SvnMockApp.Application.Run (System.String[] args) [0x00000]
  at PumaCode.SvnDotNet.SubversionSharp.SvnMockApp.Application.Main (System.String[] args) [0x00000]

Using MONO_DEBUG_LEVEL="debug", we get the following log pasted here.

At the tail end of the log, we see this:

.
.
.
Mono-INFO: DllImport attempting to load: 'libapr-1'.
Mono-INFO: DllImport loading location: 'libapr-1.so'.
Mono-INFO: DllImport error loading library: 'libapr-1.so: cannot open shared object file: No such file or directory'.
Mono-INFO: DllImport loading library: './libapr-1.so'.
Mono-INFO: DllImport error loading library './libapr-1.so: cannot open shared object file: No such file or directory'.
Mono-INFO: DllImport loading: 'libapr-1'.
Mono-INFO: DllImport error loading library 'libapr-1: cannot open shared object file: No such file or directory'.
Mono-INFO: DllImport attempting to load: 'libapr-1'.
Mono-INFO: DllImport loading location: 'libapr-1.so'.
Mono-INFO: DllImport error loading library: 'libapr-1.so: cannot open shared object file: No such file or directory'.
Mono-INFO: DllImport loading library: './libapr-1.so'.
Mono-INFO: DllImport error loading library './libapr-1.so: cannot open shared object file: No such file or directory'.
Mono-INFO: DllImport loading: 'libapr-1'.
Mono-INFO: DllImport error loading library 'libapr-1: cannot open shared object file: No such file or directory'.
Mono-INFO: DllImport attempting to load: 'libapr-1'.
Mono-INFO: DllImport loading location: 'libapr-1.so'.
Mono-INFO: DllImport error loading library: 'libapr-1.so: cannot open shared object file: No such file or directory'.
Mono-INFO: DllImport loading library: './libapr-1.so'.
Mono-INFO: DllImport error loading library './libapr-1.so: cannot open shared object file: No such file or directory'.
Mono-INFO: DllImport loading: 'libapr-1'.
Mono-INFO: DllImport error loading library 'libapr-1: cannot open shared object file: No such file or directory'.
An exception was thrown by the type initializer for PumaCode.SvnDotNet.AprSharp.Apr

I've tried to symlink the appropriate modules in the directory where SvnTest.exe exists, but this still persist.

How can I fix this?

Did I place the PumaCode.SvnDotNet.dll.config in the wrong folder? (I placed it at /bin/Debug and also tried /bin)

What can I do to remedy this?

Thank you for your kind help! Much appreciated!

Heres the config file:

(PumaCode.SvnDotNet.dll.config)

<configuration>
     <dllmap dll="libapr" target="/usr/lib/libapr-1.so.0"/>
     <dllmap dll="svn_client-1" target="/usr/lib/libsvn_client-1.so.0"/>
</configuration>
A: 

Your config file does not have the right dll reference. In the logs, Mono tries to load the libapr-1 library, but your config file has only an entry with libapr. I think the right mapping should be:

<configuration>
    <dllmap dll="libapr-1" target="/usr/lib/libapr-1.so.0"/>
    <dllmap dll="svn_client-1" target="/usr/lib/libsvn_client-1.so.0"/>
</configuration>
Laurent Etiemble
Hmm. Interesting. I tried your method but not working still. Where would you place the *.dll.config file?
nubela
The config should be placed next to the DLL in same folder. Does the Mono log shows some new information, or at least that the config file get picked up ?
Laurent Etiemble
A: 

Solved it by manually adding the dllmap into /etc/mono/config , not the best way, but at least it worked.

nubela