它確實對我有用。使用可執行文件Test773.exe將該文件命名爲Test773.exe.config,並指定dll映射。該文件與exe文件位於同一目錄中嗎?它是否在MonoDevelop中標有「複製到輸出」選項?
應用程序的源代碼:
using System;
using System.Runtime.InteropServices;
namespace Test773
{
class MainClass
{
public static void Main(string[] args)
{
Funkcja();
}
[DllImport("libIL")]
public static extern void Funkcja();
}
}
配置文件的內容拷貝從你的問題粘貼。執行的效果:
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
編輯: 要跟蹤/調試這一點,你可以使用MONO_LOG_LEVEL
。例如:
MONO_LOG_LEVEL=debug mono Test773.exe | grep config
結果:
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'.
你是天才,這確實是問題!該文件未被複制到輸出目錄。非常感謝! –
我真的很感激它,如果你可以看看我在這裏有另一個問題:http://stackoverflow.com/questions/19522244/bundling-dylib-files-with-mono-executable –