Итак, имеем
interface.cs
namespace Sample {
public interface IModule {
string name ();
}
}
module.cs
namespace Sample {
public class Module: IModule {
public string name () {
return "sample!";
}
}
}
loader.cs
using System;
using System.Reflection;
namespace Sample {
public class Loader {
static void Main () {
var module = Assembly.Load ("module.so");
var types = module.GetTypes ();
foreach (Type t in types) {
if (t.GetInterface ("IModule") != null) {
var inst = (IModule) Activator.CreateInstance (t, null);
Console.WriteLine (inst.name ());
}
}
}
}
}
Компиляем:
tokamak% gmcs interface.cs loader.cs -out:loader.exe
tokamak% gmcs interface.cs module.cs -t:library -out:module.so
И запускаем:
tokamak% mono loader.exe
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'module.so' or one of its dependencies. The system cannot find the file specified.
File name: 'module.so'
at System.AppDomain.Load (System.String assemblyString, System.Security.Policy.Evidence assemblySecurity, Boolean refonly) [0x00000] in <filename unknown>:0
at System.AppDomain.Load (System.String assemblyString) [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.AppDomain:Load (string)
at System.Reflection.Assembly.Load (System.String assemblyString) [0x00000] in <filename unknown>:0
at Sample.Loader.Main () [0x00000] in <filename unknown>:0
А теперь внимание, вопрос: что я делаю не так?
Пробовал в NetBSD 5.0.2 (mono 2.6.4) и в давно заброшенном Debian Experimental (mono 2.6.7) - одна фигня.