如何从我的 C# 主项目中调用用 C# 编写的 DLL,而不使用using statement
?
就像CreateObject(servername.typename[,location])
在 VB 中一样。
如何从我的 C# 主项目中调用用 C# 编写的 DLL,而不使用using statement
?
就像CreateObject(servername.typename[,location])
在 VB 中一样。
在 DLL 和主项目中保持相同的命名空间。
.Net 框架中与 VB6 的 CreateObject 调用等效的最接近的方法如下:
object calcInstance = Activator.CreateInstance(calcType);
or
Assembly testAssembly = Assembly.LoadFile(@"c:\Test.dll");
你能解释一下你的场景吗?您是否正在创建某种“插件”架构,在其中您不知道哪些插件在运行时才可用?如果是这样,是的,反思会让你到达你需要去的地方,但还有更好的方法。