Method By Method Comparison
Hi guys,
I've been given an assignment on comparing methods that were written in VB6 as our old application. Theses DLLs are purely VB6. And we also do have C#.Net methods (New version of the application) the same as VB6, same DLL filename.
Now, I need to know if there is a built-in application or C#.NET Classes that could compare methods of vb6 versus C#.net.
Say in myServices.DLL (VB6) has 10 methods and myServices.DLL(C#.NET) has 9 methods. I need to know on how to count/compare DLLs' methods.
1. is there something like isMethod() ?
2. How to know if abcd() is a method?
Please guide me.
Thank you.
Re: Method By Method Comparison
I believe you can use Reflection for this in.NET, I'll try put together an example. As for counting the methods in a VB6 project... not so sure on that one I'm afraid
EDIT: Here's a VB.NET example, say your class was named Services you could do this to find out how many methods it had in it:
Code:
Services.GetType.GetMethods.Count()
but I think that might only count the public methods... as you can tell im not exactly an expert at this type of thing :D but hopefully that gives you something to go on..
Re: Method By Method Comparison
Thank you for the reply. I'll check Reflection in C#.Net.
Re: Method By Method Comparison
chris,
thanks again and this is what am looking for. But it seems Reflection is for C# only, right? I need this too. But on the same thing, how will I know all the methods in VB6 ?
Because am going to compare VB6 methods to C# methods, my source is vb6.
thanks again.
Re: Method By Method Comparison
I dunno like I said im not great with VB6 so cant help you there :( might be worth having a quick google search, like so: http://www.google.co.uk/search?hl=en...=0&oq=vb6+refl
Re: Method By Method Comparison
There is a library you can use in VB6 to "query" dll information. Add a reference to the TypeLib Information library (tlbinf32.dll) to your VB project.
With this TypeLib library you have several ways to get and filter the info from a DLL. The following sample code should help get you started. It does help a little to understand how COM works but it is easy enough to figure out which information applies to your methods/properties.
Code:
Dim objTLI As TLI.TLIApplication
Dim objLib As TLI.TypeLibInfo
Dim objInterfaceInfo As TLI.InterfaceInfo
Dim objMemberInfo As TLI.MemberInfo
Set objTLI = New TLI.TLIApplication
Set objLib = objTLI.TypeLibInfoFromFile("C:\WINDOWS\system32\syscommon.dll")
For Each objInterfaceInfo In objLib.Interfaces
For Each objMemberInfo In objInterfaceInfo.Members
Debug.Print objInterfaceInfo.Name, objMemberInfo.Name, objMemberInfo.InvokeKind
Next
Next
There is a class in my SysCommon dll called Application and the above code returns the following.
_Application QueryInterface 1
_Application AddRef 1
_Application Release 1
_Application GetTypeInfoCount 1
_Application GetTypeInfo 1
_Application GetIDsOfNames 1
_Application Invoke 1
_Application AppGroup 2
_Application Codes 2
_Application DataSource 2
_Application Environment 2
_Application Reports 2
_Application IsUserInRole 1
_Application Login 1
_Application LoginDirect 1
Every COM class includes the methods from QueryInterface to Invoke. The rest are either Properties (2) or Methods(1) of my class.
Re: Method By Method Comparison
brucevde,
Thank you very very much for that wonderful help. I'll surely try this code of yours.