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. How do you create an object from a C++ DLL in C#

How do you create an object from a C++ DLL in C#

Scheduled Pinned Locked Moved C#
questioncsharpc++
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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi, I have a c++ DLL it contains a class called MyClass with methods GetName and SetName. [DllImport("MyClass.dll")] public static extern void GetName( string name); This doesn't work because I need to instanciate the class. How do I declare the class and methods within the class? Then how do I instancial the class and call the method? Thanks Mike

    N 1 Reply Last reply
    0
    • L Lost User

      Hi, I have a c++ DLL it contains a class called MyClass with methods GetName and SetName. [DllImport("MyClass.dll")] public static extern void GetName( string name); This doesn't work because I need to instanciate the class. How do I declare the class and methods within the class? Then how do I instancial the class and call the method? Thanks Mike

      N Offline
      N Offline
      Nemanja Trifunovic
      wrote on last edited by
      #2

      No way to do this from C#. Either use MC++, or wrap your class into a COM object and the reference it from your code. I vote pro drink :beer:

      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