如何从 C# 访问和理解旧的 dll
我得到了一个旧的 dll 并分配了通过 C# .NET 3.5 访问它的任务。我相信该 dll 最初是用 VB6 构建的,但我并不肯定。除了如何在 VB6 中使用它的示例之外,没有该 dll 的文档或源代码。我已经能够通过VB.NET 3.5成功访问它。用于访问的示例代码如下所示:
myLib = CreateObject("MyLib.api")
myConnection = myLib.CreateObject("NameOfConnectionObject")
myConnection.do_something("abc")
从库中创建了几个不同的对象,并且所有这些对象都有不同的方法。我尝试使用不同的 dll 读取工具,但所有导出方法都显示为垃圾。我还尝试在 Visual Studio 中导入 dll,但收到错误消息,指出 dll 不可访问和/或不是 COM 对象或程序集。因此,我只了解旧文档中的方法,而这些方法很少。
关于如何在 C# 中访问和/或了解有关这个神秘 dll 的更多信息,有什么想法吗?
谢谢!
I have been given an old dll and the assignment of accessing it through C# .NET 3.5. I believe the dll was originally built with VB6, but am not positive. There is no documentation or source for the dll aside from an example for how to use the it in VB6. I have been able to succesfully access it through VB.NET 3.5. Example code for accessing looks like this:
myLib = CreateObject("MyLib.api")
myConnection = myLib.CreateObject("NameOfConnectionObject")
myConnection.do_something("abc")
There are several different objects that are created from the library and all of those objects have different methods. I tried using different dll reading tools, but all the export methods show up as garbage. I also tried importing the dll in visual studio, but I get an error stating the dll is not accessible and/or not a COM object or assembly. So, I only know about the methods from the old documentation which is sparse.
Any ideas on how to access in C# and/or find out more about this mystery dll?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
代码片段使用了后期绑定,它绝对是一个COM服务器。如果它是用 VB6 编写的,那么它也应该有一个类型库。如果您无法从 Visual Studio 添加对它的引用,则可能性很低,但我见过一些失败的情况,但 Tlbimp.exe 没有问题。从 Visual Studio 命令提示符运行它。您还可以运行 OleView.exe 并使用 File + View Typelib 查看类型库。
如果这些尝试失败,那么您就完成了,您无法在没有文档的情况下对该 COM 组件进行逆向工程。坦率地说,无论如何,这都是相当危险的。如果这个 COM 组件的原始供应商倒闭了,那么至少应该有一个程序员仍然记得从事过这个工作。他可能正在阅读,但除非你留下一些名字,否则他找不到你。
The code snippet is using late binding, it is definitely a COM server. If it was written in VB6 then it should also have a type library. The odds are low if you can't add a reference to it from Visual Studio but I've seen a few cases where it failed but Tlbimp.exe had no problem. Run it from the Visual Studio Command Prompt. You can also run OleView.exe and use File + View Typelib to look at the type library.
If these attempts fail then you're done, you can't reverse engineer this COM component without documentation. Which, frankly, is fairly risky anyway. If the original supplier of this COM component is out of business then there ought to be at least a programmer that still remembers working on this. He might be reading SO but he can't find you until you drop some names.
你试过反光镜吗? http://www.red-gate.com/products/reflector/ ?
编辑:反射器不适用于非.net程序集,这是VB6,所以这不是一个可行的解决方案
Have you tried reflector ? http://www.red-gate.com/products/reflector/ ?
EDIT: reflector doesnt work with non .net assemblies, and this is VB6, so this is not a viable solution