【发布时间】:2023-03-20 17:54:01
【问题描述】:
我想覆盖 DLL 导出中的静态方法
public class Export {
[DllExport] public static string plugin_name() { return Plugin.Instance.plugin_name(); }
}
public class Plugin<T> where T: Plugin<T>, new()
{
private static readonly Lazy<T> val = new Lazy<T>(() => new T());
public static T Instance { get { return val.Value; } }
protected Plugin() { }
public new static string plugin_name() { }
}
}
所以现在这些类都在一个 dll 文件中,我希望使用 dll 的人只在主类中这样做。
public class Main : Plugin<Main> {
public override string plugin_name() {
return "a test plugin";
}
}
我已经测试了几个小时但失败了。
【问题讨论】:
-
您不能对 [DllExport] 代码提出任何要求。 Main 类肯定不是 C 程序员使用它的方式。
标签: c#