C# COM 组件适用于 VB6,但不适用于 VB5 — 这是怎么回事?
在之前的一个问题中,我试图让一个 C# 类充当 VB5 和 VB5 的 COM 对象。 6. 我确实设法让 COM 对象与 VB6 应用程序一起工作,但在同一台机器上使其与 VB5 一起工作时遇到了问题。
作为参考,之前的问题是 此处。
我的最终目标是让这个 COM 对象适用于 VB5,但是当它运行时会抛出异常:运行时错误 80070002。Stackoverflow 上的研究表明 此处该错误代码是文件未找到异常。 VB6 程序能够与 VB5 程序在同一台计算机上运行(相同的代码),COM DLL 已正确注册(使用 regasm.exe),并且 TLB 显示在 VB5 的引用列表中。执行代码是:
Dim arcom As ARCOMObject.ARCOM_Class
Set arcom = New ARCOMObject.ARCOM_Class
Dim s As String
s = arcom.GetServiceResponse()
MsgBox (s)
在执行实例化类的行时抛出异常。
在我发现的其他地方,特别是在我上面所做的第二个SO参考中,建议使用实用程序depends.exe来查看可能缺少哪些依赖项。不幸的是,我无法找到任何这样的实用程序,无论是在我的 .Net 开发机器上还是在 VB5 机器上。我不确定这是否会告诉我任何事情,但是...
那么,VB5 看不到什么,而 VB6 可以看到或不需要呢?
编辑添加:
重要警告 - 因为它在从 IDE 运行时抛出错误,所以我从未构建可执行文件来运行它,但是当我最终尝试并这样做是因为 DependencyWalker 需要它,我发现可执行文件本身工作正常!现在,DependencyWalker 向我显示消息“警告:由于延迟加载依赖模块中缺少导出函数,至少有一个模块存在未解析的导入”。哇,太酷了,这句话到底是什么意思?哈哈。
无论如何,我不确定目前是否有需要解决的问题,但欢迎任何建议!
In an earlier question I was attempting to get a C# class functioning as a COM object for VB5 & 6. I did manage to get the COM object working with a VB6 app, but have had a problem getting it work with VB5 -- on the same machine.
For reference, the earlier question is HERE.
My ultimate goal is to get this COM object working for VB5, but when it runs it throws an exception: Runtime Error 80070002. Research on Stackoverflow indicates HERE that this error code is a File not Found exception. The VB6 program is able to run on the same machine as the VB5 program (identical code), the COM DLL is properly registered (using regasm.exe) and the TLB shows up in the list of references in VB5. The executing code is:
Dim arcom As ARCOMObject.ARCOM_Class
Set arcom = New ARCOMObject.ARCOM_Class
Dim s As String
s = arcom.GetServiceResponse()
MsgBox (s)
The exception is thrown upon execution of the line instantiating the class.
In other places I have found, especially in the second SO reference I have made above, a suggestion has been made to use the utility depends.exe to see what dependency might be missing. Unfortunately, I am unable to find any such utility, neither on my .Net dev machine, nor on the VB5 machine. I'm not sure if this would tell me anything anyway, but...
So, what can't VB5 see, that VB6 either can see or doesn't need?
EDITED TO ADD:
Important Caveat -- Because it threw the error while being run from the IDE I never built the executable to run it, but when I finally took a shot and did so because DependencyWalker needs it, I found the executable itself worked OK! Now, DependencyWalker gives me the message "Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module." Wow, that's cool, what on earth does this sentence mean? LOL.
Anyway, I'm not sure that I have a problem that needs solving at the moment, but any suggestions are welcomed!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当我陷入解决这些类型的问题时,这总是对我有用。您的问题是 VB5 版本在某处缺少一个文件,因此您需要知道是哪个文件。简单的解决方案(不诉诸 WinDBG)是抛出 FileMon 或 ProcMon - 对其进行过滤,以便您只看到失败。
然后,当您的应用程序失败时,您将看到丢失了哪个文件。
Here is what always works for me when I am stuck resolving these types of issues. Your issue is that the VB5 version is missing a file somewhere down the line, so you need to know which one. The easy solution (without resorting to WinDBG) is to throw FileMon or ProcMon - filter it so that you only see failures.
Then when your app fails, you'll see which file was missing.
这可能很有趣:
至少由于隐式依赖模块中缺少导出函数,一个模块存在未解析的导入
this might be interesting:
At least one module has an unresolved import due to a missing export function in an implicitly dependent module