Creating Interop Wrapper
-
Hi All, I've a class file written using VB 6.0. The class file has some complex methods. Now I need to use that methods in my C# project. It is too hard to convert the Vb code to C#. By googling I came to know that, we can create interop wrapper to attain this goal.But I'm not aware of interop wrapper even what is that. Pls. can anyone give me the urls or sample code on this topic ?. Your help would be greatly appreciated. DHARMA.R
-
Hi All, I've a class file written using VB 6.0. The class file has some complex methods. Now I need to use that methods in my C# project. It is too hard to convert the Vb code to C#. By googling I came to know that, we can create interop wrapper to attain this goal.But I'm not aware of interop wrapper even what is that. Pls. can anyone give me the urls or sample code on this topic ?. Your help would be greatly appreciated. DHARMA.R
You'll have to expose the VB code as an ActiveX DLL, enabling you to use .NET's COM interop support. Here's an MSDN article that talks you through it: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcwlkCOMInteropPart1CClientTutorial.asp[^] You'll need to scroll down a bit, to where it says Example 1: Using Tlbimp. This imports the type library, creating a managed gateway to the COM interfaces implemented by the server. All you have to do then is ensure you reference the generated assembly when compiling. Alternatively, (if you want) you can actually declare the interfaces and GUIDs inside C# through applying attributes. Again, this is documented inside the MSDN article. However, if you've got a large interface you will probably prefer the automated approach. For more information about .NET's interoperability, you'll definitely want to check out this section in MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconinteroperatingwithunmanagedcode.asp[^] It covers things like threading, marshaling of types, lifecycle etc. -- Paul "Put the key of despair into the lock of apathy. Turn the knob of mediocrity slowly and open the gates of despondency - welcome to a day in the average office." - David Brent, from "The Office" MS Messenger: paul@oobaloo.co.uk Download my PGP public key