开发者

How to access and understand old dll from C#

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!


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜