[Mono-list] Bug in Assembly.Load()?
J. Perkins
jason@379.com
26 Nov 2002 10:09:16 -0500
It appears that Assembly.Load() doesn't work in the latest snapshot. I
will start looking into it this afternoon, but I thought I'd post a
quick note in case someone else has already figured it out. The problem
looks like:
1) Define a plugin interface in a library Support.dll
using System;
namespace AppSpace
{
public interface IPlugin
{
void DoSomething();
}
}
> mcs /t:library Support.cs
2) Create a plugin in a library Plugin.dll
using System;
namespace AppSpace
{
public class MyPlugin : IPlugin
{
public void DoSomething()
{
Console.WriteLine("Plugin loaded successfully!");
}
}
}
> mcs -t:library -r:Support.dll Plugin.cs
3) Load the plugin from App.exe
using System;
using System.Reflection;
namespace AppSpace
{
public class App
{
static void Main()
{
Console.WriteLine("Loading plugin...");
Assembly assembly = Assembly.Load("Plugin");
Type type = assembly.GetType("AppSpace.MyPlugin", true, true);
IPlugin plugin = (IPlugin)Activator.CreateInstance(type);
plugin.DoSomething();
}
}
}
> mcs /r:Support.dll App.cs
Build and run this with mcs and the latest code snapshot and get:
Unhandled Exception: System.IO.FileNotFoundException: File 'Plugin' not
found.
in (unmanaged) 06 System.AppDomain:LoadAssembly
(System.Reflection.AssemblyName,System.Security.Policy.Evidence)
in <0x00004> 06 System.AppDomain:LoadAssembly
(System.Reflection.AssemblyName,System.Security.Policy.Evidence)
in <0x00017> 00 System.AppDomain:Load
(System.Reflection.AssemblyName,System.Security.Policy.Evidence)
in <0x00067> 00 System.AppDomain:Load (string)
in <0x00061> 00 AppSpace.App:Main ()
Has anyone else seen this? I didn't see anything in bugzilla directly
related to this (though there are other open bugs for Assembly).
Thanks,
Jason
379