在VB6应用消费.NET的DLL [英] Consuming .NET dll in VB6 application
问题描述
我写在C#.net一个DLL调用该应用程序中的其他第三方.NET的DLL。这工作得很好,当我写在C#.NET控制台应用程序测试它使用下面的代码,以及:
I wrote a dll in c#.net that calls another third party .NET dll within the application. This works fine when I tested it with a console application written in c#.NET as well using the code below:
Assembly u = Assembly.LoadFrom(dllLocation);
Type t = u.GetType("MyLIB.CLass");
MethodInfo m = t.GetMethod("Method");
object[] myparam = new object[1];
myparam[0] = fileLocation;
result = (string)m.Invoke(null, myparam);
请注意,某些文件所在的DLL最初加载以及使用的位置中加载:
Please note that some files are loaded within the location where the dll was initially loaded as well using:
string path = Assembly.GetExecutingAssembly().Location;
path = Path.GetDirectoryName(path);
但问题是,当我试图呼叫使用VB6,我得到一个错误,它无法加载第三方DLL。请帮助我似乎不知道发生了什么事情。
But the issue is that when I tried to call it using VB6, I get an error that it cannot load the third party dll. Please help as I seem not to know what's going on.
推荐答案
我想给你更多的细节,以便.NET大会暴露在COM
I would thought to give you more detail, in order .NET Assembly expose to COM
您需要生成 TBL - 类型库
使用 RegAsm / TLB:MyLIB.tlb中是指mylib.dll
有指南以揭露.NET类型为COM,并确保你应付的。
,如申报的 ComVisibleAttribute ,需要一个公共的默认构造函数是可见的COM,如在
There are Guidelines to expose .NET Types to COM and make sure you cope with that. such as declare ComVisibleAttribute , require a public default constructor to be visible to COM , such are in
您可以参考,在
如何调用一个Visual Basic .NET或Visual Basic从Visual Basic 6.0
这篇关于在VB6应用消费.NET的DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!