I have this function:
public void LoadPlugins()
{
foreach (FileInfo f in new DirectoryInfo(pDir).GetFiles())
{
if (f.Extension.ToLower() != ".dll")
continue;
try {
string path = f.FullName;
Assembly DLL = Assembly.LoadFile(path);
foreach (Type t in DLL.GetExportedTypes())
{
if (t.Equals(typeof(IPlugin)))
{
IPlugin plugin = (IPlugin)Activator.CreateInstance(t);
plugin.Initialize(prgm, players);
if (Plugins.ContainsKey(plugin.PluginName))
{
prgm.LogMessage("Duplicate plugin name detected: \"" + plugin.PluginName + "\"", LogLevel.Error);
continue;
}
Plugins.Add(plugin.PluginName, plugin);
}
}
}
catch (Exception e)
{
prgm.LogMessage(e.Message, LogLevel.Error);
}
}
}
It should load DLL's from the plugins folder into a dictionary of plugins, but the line:
Assembly DLL = Assembly.LoadFile(path);
keeps returning a BadImageFormatException. I have checked and the .net framework version is the same in both the dll and the loader, and they are both built for x86 architecture, I have tried rebuilding it just in case the one build had become corrupt, I have no idea why I continue to receive an error.
Call Stack:
> CorpHack.exe!CorpHack.Plugin.PluginLoader.LoadPlugins() Line 56 C#
CorpHack.exe!CorpHack.Plugin.PluginLoader.NewLoadPlugins(string dir, CorpHack.AdminWindow program) Line 76 C#
CorpHack.exe!CorpHack.AdminWindow.Form1_Load(object sender, System.EventArgs e) Line 102 C#
[External Code]
CorpHack.exe!CorpHack.Program.Main(string[] args) Line 20 C#
[External Code]
The message from the exception:
Could not load file or assembly 'BasePlugin.dll' or one of its dependencies. is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)
More exception details:
http://hastebin.com/pokuvuvere.tex[
^]
Regards,
Jordan