【发布时间】:2011-07-04 05:06:54
【问题描述】:
如何在不使用 using statement 的情况下从我的 C# 主项目中调用用 C# 编写的 DLL?
与 VB 中的 CreateObject(servername.typename[,location]) 一样。
【问题讨论】:
标签: c# .net dll call late-binding
如何在不使用 using statement 的情况下从我的 C# 主项目中调用用 C# 编写的 DLL?
与 VB 中的 CreateObject(servername.typename[,location]) 一样。
【问题讨论】:
标签: c# .net dll call late-binding
.Net 框架中与 VB6 的 CreateObject 调用等效的最接近的方法如下:
object calcInstance = Activator.CreateInstance(calcType);
or
Assembly testAssembly = Assembly.LoadFile(@"c:\Test.dll");
【讨论】:
在 DLL 和主项目中保持相同的命名空间。
【讨论】:
Nike.Shoes.CreateObject().
你能再解释一下你的场景吗?您是否正在创建某种“插件”架构,在其中您不知道哪些插件在运行时才可用?如果是这样,是的,反思会让你到达你需要去的地方,但还有更好的方法。
【讨论】: