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 a C++ library for use in C# project

Creating a C++ library for use in C# project

Scheduled Pinned Locked Moved C#
csharpc++visual-studioquestionlounge
4 Posts 4 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
    SRogers88
    wrote on last edited by
    #1

    Hello, I am trying to create a dll using c++ that I can then use and call functions out of in C#. I have a general idea of what to do, but I don't know the specifics. I am using visual studio 2005. What type of project should I create in c++? Does anyone know of any source code out there that might have some simple exambles? Once I have created my dll, I add it to C# as a reference. But after that what do I do?

    Richard Andrew x64R A N 3 Replies Last reply
    0
    • S SRogers88

      Hello, I am trying to create a dll using c++ that I can then use and call functions out of in C#. I have a general idea of what to do, but I don't know the specifics. I am using visual studio 2005. What type of project should I create in c++? Does anyone know of any source code out there that might have some simple exambles? Once I have created my dll, I add it to C# as a reference. But after that what do I do?

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      You would use Platform Invoke to call from C# into the DLL. Read the help for Platform Invoke.

      “Cannot find REALITY.SYS...Universe Halted.” ~ God on phone with Microsoft Customer Support

      1 Reply Last reply
      0
      • S SRogers88

        Hello, I am trying to create a dll using c++ that I can then use and call functions out of in C#. I have a general idea of what to do, but I don't know the specifics. I am using visual studio 2005. What type of project should I create in c++? Does anyone know of any source code out there that might have some simple exambles? Once I have created my dll, I add it to C# as a reference. But after that what do I do?

        A Offline
        A Offline
        Anthony Mushrow
        wrote on last edited by
        #3

        Depends, if your using the .Net framework for the c++ DLL then you use it like any other class. If you're not using the .Net framework for the c++ dll then you will have to use P/Invoke As for the type of project to make, I think you just need to make a Class Library.

        My current favourite word is: Nipple!

        -SK Genius

        Game Programming articles start -here[^]-

        1 Reply Last reply
        0
        • S SRogers88

          Hello, I am trying to create a dll using c++ that I can then use and call functions out of in C#. I have a general idea of what to do, but I don't know the specifics. I am using visual studio 2005. What type of project should I create in c++? Does anyone know of any source code out there that might have some simple exambles? Once I have created my dll, I add it to C# as a reference. But after that what do I do?

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          Is there any specific reason why you need the dll in C++? If your C++ dll is on .NET framework, you can directly add reference to your c# project. Alternatively, you can use C++/CLI other than C#. So you can use the C++ classes by just importing the necessary headers.

          Navaneeth How to use google | Ask smart questions

          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