I'm working on an API and plugin using it. I am trying to get the class of Plugin that refers to the Mod class in the API, and in the API, when IssignbleFrom(type) comes a false. how can i do?
API.dll
Loader.cs
...
string[] files = Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), "Mods"), "*.dll");
foreach (var file in files)
{
AddLog(" mod loader : " + file);
try
{
var asm = Assembly.LoadFile(file);
foreach (Type type in asm.GetTypes())
{
AddLog("[Debug] " + type + " > " + type.BaseType + " > " + type.IsSubclassOf(typeof(Mod)) + " > " + typeof(Mod).IsAssignableFrom(type));
if (type.IsSubclassOf(typeof(Mod)) && type != typeof(Mod))
{
Mod mod = (Mod) Activator.CreateInstance(type);
mod.Register();
AddLog(" Mod Loaded : " + type);
}
}
}
catch (Exception e)
{
AddLog(" Failed to create instance of mod.\n" + e.ToString());
}
...
Mod.cs
namespace SLModder {
public abstract class Mod {
public abstract void Register();
}
}
Plugin.dll
Main.cs
namespace PracticePlugin {
public class Main : Mod
{
public override void Register() {
ServerConsole.AddLog("Plugin Enabled");
}
}
}
Console
[Debug] PracticePlugin.Main > SLModder.Mod > false > false