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. Calling a class exported by a custom DLL in C#

Calling a class exported by a custom DLL in C#

Scheduled Pinned Locked Moved C#
csharpc++helpquestion
3 Posts 3 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.
  • V Offline
    V Offline
    Vini Deep
    wrote on last edited by
    #1

    Hi, I have a custom dll in C++ which exports a class with certain member functions. I want to call the methods from a c# application. I am able to call the member functions seperately using the DllImports[....]. Is it possible to instantiate an object of the exported class from the C# tester application? Kindly help. Is there any link which would give me this detail. Is the source code of the DLL necessary for this. Thanks, Regards, Vini

    S H 2 Replies Last reply
    0
    • V Vini Deep

      Hi, I have a custom dll in C++ which exports a class with certain member functions. I want to call the methods from a c# application. I am able to call the member functions seperately using the DllImports[....]. Is it possible to instantiate an object of the exported class from the C# tester application? Kindly help. Is there any link which would give me this detail. Is the source code of the DLL necessary for this. Thanks, Regards, Vini

      S Offline
      S Offline
      sammyh
      wrote on last edited by
      #2

      If it where me, I would create a wrapper in Managed C++, then call that from c#. That way you could totally avoid DllImports. DllImports is fine and dandy for most functions, especially win32, but once you hit a function with some off the wall data structure it turns into a pain real quick. -Sam

      1 Reply Last reply
      0
      • V Vini Deep

        Hi, I have a custom dll in C++ which exports a class with certain member functions. I want to call the methods from a c# application. I am able to call the member functions seperately using the DllImports[....]. Is it possible to instantiate an object of the exported class from the C# tester application? Kindly help. Is there any link which would give me this detail. Is the source code of the DLL necessary for this. Thanks, Regards, Vini

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        You can do this using a class factory and the CallingConvention.ThisCall calling-convention. See the CallingConvention enumeration[^] documentation for a little information about the various calling conventions and how they're used, and a previous post of mine about how to use it: http://www.codeproject.com/script/comments/forums.asp?msg=771919&forumid=1649&XtraIDs=1649&searchkw=ThisCall&sd=11%2F15%2F1999&ed=4%2F12%2F2004#xx771919xx[^].

        Microsoft MVP, Visual C# My Articles

        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