I have to export 3 basic methods from my DLL in C#, so it becomes accessible in C++:
- OnPluginStart
- OnPluginStop
- PluginUpdate
So I found Unmanaged Exports a nice C# library that makes that easier.
So I went ahead with a sample code to test:
using System;
using System.IO;
using RGiesecke.DllExport;
namespace Plugins
{
public class Plugins
{
[DllExport("OnPluginStart", CallingConvention = CallingConvention.StdCall)]
public static void OnPluginStart()
{
using (var file = new StreamWriter(@"pluginLog.txt", true))
{
file.WriteLine("OnPluginStart");
}
}
[DllExport("OnPluginStop", CallingConvention = CallingConvention.StdCall)]
public static void OnPluginStop()
{
using (var file = new StreamWriter(@"pluginLog.txt", true))
{
file.WriteLine("OnPluginStop");
}
}
[DllExport("PluginUpdate", CallingConvention = CallingConvention.StdCall)]
public static void PluginUpdate(float dt)
{
using (var file = new StreamWriter(@"pluginLog.txt", true))
{
file.WriteLine("PluginUpdate");
}
}
}
}
However, when I compile my DLL and use DLL Exporter Viewer it doesn't list any of the exported functions and the application the DLL is loaded into also never runs my plugin.
What am I doing wrong here which makes my functions not being exported at all?