4

I've added an app.config file to my project by right-clicking on the solution => Add => New File => Misc => Application Configuration File, and named it "LightmapUpdater.exe.config". "LightmapUpdater.exe" is the name of my executable. Here's what the config file has inside:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <dllmap dll="libIL" target="/opt/local/lib/libil.dylib" />
</configuration>

No matter what mistakes I intentionally make in the file, it keeps ignoring them, not giving me even a single warning. Is it supposed to be that way? Why is it ignoring everything I type in there? How can I make sure that mono looks inside of my config file before compiling? I must be missing some step.

1 Answer 1

6

It does work for me. With executable file Test773.exe the file is named Test773.exe.config and the dll mapping specified takes place. Is the file in the same directory as the exe file? Is it marked with a "Copy to output" option in MonoDevelop?

The source code of the application:

using System;
using System.Runtime.InteropServices;

namespace Test773
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            Funkcja();
        }

        [DllImport("libIL")]
        public static extern void Funkcja();
    }
}

The content of the config file is copy pasted from your question. The effect of the execution:

Unhandled Exception:
System.DllNotFoundException: /opt/local/lib/libil.dylib
  at (wrapper managed-to-native) Test773.MainClass:Funkcja ()
  at Test773.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: /opt/local/lib/libil.dylib
  at (wrapper managed-to-native) Test773.MainClass:Funkcja ()
  at Test773.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0

EDIT: To trace/debug this you can use MONO_LOG_LEVEL. For example:

MONO_LOG_LEVEL=debug mono Test773.exe | grep config

results in:

Mono: Config attempting to parse: '/usr/lib/mono/4.5/mscorlib.dll.config'.
Mono: Config attempting to parse: '/usr/etc/mono/assemblies/mscorlib/mscorlib.config'.
Mono: Config attempting to parse: '/usr/etc/mono/config'.
Mono: Config attempting to parse: '/home/konrad/.mono/config'.
Mono: Config attempting to parse: '/home/konrad/eksperymenty/Test773/Test773/bin/Debug/Test773.exe.config'.
Mono: Config attempting to parse: '/usr/etc/mono/assemblies/Test773/Test773.config'.
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.