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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. need help on adding C++ project

need help on adding C++ project

Scheduled Pinned Locked Moved C#
csharpc++helptutorialquestion
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.
  • S Offline
    S Offline
    skinnyreptile
    wrote on last edited by
    #1

    I created a C# project and I would like to call functions in my existing C++ project, so I add the C++ project to my C# solution. Can someone please tell me how to call a C++ function from a C# project? Thank you for your great help.

    J H 2 Replies Last reply
    0
    • S skinnyreptile

      I created a C# project and I would like to call functions in my existing C++ project, so I add the C++ project to my C# solution. Can someone please tell me how to call a C++ function from a C# project? Thank you for your great help.

      J Offline
      J Offline
      japanreddy
      wrote on last edited by
      #2

      you need to add reference to the project in your C# project. This is a guess.

      1 Reply Last reply
      0
      • S skinnyreptile

        I created a C# project and I would like to call functions in my existing C++ project, so I add the C++ project to my C# solution. Can someone please tell me how to call a C++ function from a C# project? Thank you for your great help.

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

        If this is a Managed C++ project, then it produces an assembly that you can use like any other assembly in your C# project. If you want to call exported native functions, you need to learn about Platform Invoke. Read Consuming Unmanaged DLL Functions[^] and Marshaling Data with Platform Invoke[^]. If your project is a native VC++ project, your C# doesn't need a reference to it. Just make sure the compiled DLL is resolvable (i.e., either in the application's directory or in a directory within the PATH environment variable). Read about the LoadLibrary API in the Platform SDK for the exact steps that the Winodws executable loader uses to resolve executables.

        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