我需要在运行时从 C# winforms 宿主项目动态加载 DLL 中的一些 .NET 控件。
例如:
1.dll contains control1
2.dll contains control2
3.dll contains control3
宿主应用程序可以加载任何此 dll-s,从 dll 获取控件并将其置于自身形式。
我试过:
__declspec(dllexport) TestCLRPlugin::Properties ^ GetControl()
{
return gcnew TestCLRPlugin::Properties();
}
但是,clrcall 方法不能从 dll 中导出。
最佳答案
您需要使用 Assembly.LoadFrom方法,然后您可以使用反射从程序集中获取您想要的方法/类/等。如果您点击 MSDN 链接,会有很好的示例。
关于c# - Clr dll .net 控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10852445/