System.MissingMethodException in runtime loaded assembly
I have a project with 3 dlls. ( MainDll, DBDll and PluginDLL )
MainDLL contains the class Main and the interface IPlugin
PluginDLL implements IPlugin.
In the ctor of MainDLL i load the PluginDLL with
object[] args = new object[1];
args[0] = this;
plugin = (IPlugin)Activator.CreateInstance( type, args );
The Plugin stores the value in args[0] for later use.
But right before the usage for args[0] i get an Exception that a method from the object is not found.
The curious thing is if IPlugin uses the missing method in its ctor, it can use it there
and everywhere else. But if it does not use it in its ctor it gets the MissingMethod Exception.
More detailed code:
MainDLL:
public class Main
{
IPlugin plugin = null;
DB xyz;
public Main()
{
// search plugin.dll
// call Assembly.LoadFrom( fileName );
// and load/create an IPlugin from the Assembly
}
public DB Other
{
get { return xyz; }
}
}
PluginDLL:
public class Plugin : IPlugin
{
Main main = null;
Plugin( Main m )
{
main = m;
// comment out the next line to get the exception
DB test = main.Other;
}
public void PluginFunc()
{
// System.MissingMethodException here, but only if commenting out
// OtherClassFromMain test = main.Other; in ctor
DB xyz = main.Other;
}
}
I`m using VS.NET 2003 and have no idea why i get this exception.
The Exception says that the get property of Main is missing,
but i guess that it has something to do with the fact that DB is from a third DLL
( which both MainDLL and PluginDLL reference )