I'm trying to create an instance of my custom class, ServerPlugin, from a DLL file, however, I'm getting the exception:
TypeLoadException: Could not load type 'ServerPlugin'.
This is my main code, that will create an instance of ServerPlugin:
public class Main : MonoBehaviour
{
void Start()
{
string path = System.IO.Path.Combine(Application.streamingAssetsPath, "ProjectIGTestMod.dll");
// Domain
AppDomain domain = AppDomain.CreateDomain("Plugin");
Type type = typeof(ServerPlugin);
// Create instance of plugin
ServerPlugin plugin = null;
try
{
plugin = domain.CreateInstanceFromAndUnwrap(path, type.FullName) as ServerPlugin;
}
catch (Exception e)
{
Debug.LogException(e);
}
// If loaded plugin
if (plugin != null)
{
// Load and enable
//plugin.onLoad();
plugin.onEnable();
}
}
}
And here is the class I'm trying to create an instance of:
namespace ProjectIGTestMod
{
public class Main : ServerPlugin
{
public void onLoad()
{
throw new System.NotImplementedException();
}
public void onEnable()
{
Debug.Log("Test Mod enabled.");
}
public void onDisable()
{
throw new System.NotImplementedException();
}
}
}
I'm not sure what exactly I'm doing wrong. I tried to follow this code.