Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Creating Interop Wrapper

Creating Interop Wrapper

Scheduled Pinned Locked Moved C#
questioncsharpcomhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DHARMA R
    wrote on last edited by
    #1

    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

    P 1 Reply Last reply
    0
    • D 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

      P Offline
      P Offline
      Paul Ingles
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups