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. Managed C++/CLI
  4. Unmanaged in manage

Unmanaged in manage

Scheduled Pinned Locked Moved Managed C++/CLI
csharpc++comdiscussion
6 Posts 4 Posters 1 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.
  • T Offline
    T Offline
    ThatsAlok
    wrote on last edited by
    #1

    Dear All, i have a Unmanaged c++ based Library and i want to use it C#/C++ application(i.e. it expose some c based function .. ).. could some one give some pointer to use unmanaged library in c#/C++.. so that i don't have to provide some extra dll or lib with c#/C++ to my end user.... thanks in advance

    "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

    cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Re

    L C K 3 Replies Last reply
    0
    • T ThatsAlok

      Dear All, i have a Unmanaged c++ based Library and i want to use it C#/C++ application(i.e. it expose some c based function .. ).. could some one give some pointer to use unmanaged library in c#/C++.. so that i don't have to provide some extra dll or lib with c#/C++ to my end user.... thanks in advance

      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

      cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Re

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      If you cannot convert the library to a managed-mixed mode assembly, and... you cannot add another DLL that is a managed-mixed mode assembly, then... I believe your remaining choice is to use PInvoke or, COM Interop if your library has any COM interfaces, from your managed application project. Keep in mind you can only deal with C API's using PInvoke (exported _cdecl functions) and/or COM interfaces, meaning you will have no access to C++ classes defined in the library from managed code. IMHO if you cannot convert the original library you should take the option of delivering another DLL that is a managed-mixed-mode assembly.

      led mike

      T 1 Reply Last reply
      0
      • T ThatsAlok

        Dear All, i have a Unmanaged c++ based Library and i want to use it C#/C++ application(i.e. it expose some c based function .. ).. could some one give some pointer to use unmanaged library in c#/C++.. so that i don't have to provide some extra dll or lib with c#/C++ to my end user.... thanks in advance

        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

        cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Re

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        That's not possible. You can't convert C++ to C#, and you can't have more than one language in your program. Certainly if you could, the two would not be C++ and C#. You need to pinvoke a dll.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        1 Reply Last reply
        0
        • L led mike

          If you cannot convert the library to a managed-mixed mode assembly, and... you cannot add another DLL that is a managed-mixed mode assembly, then... I believe your remaining choice is to use PInvoke or, COM Interop if your library has any COM interfaces, from your managed application project. Keep in mind you can only deal with C API's using PInvoke (exported _cdecl functions) and/or COM interfaces, meaning you will have no access to C++ classes defined in the library from managed code. IMHO if you cannot convert the original library you should take the option of delivering another DLL that is a managed-mixed-mode assembly.

          led mike

          T Offline
          T Offline
          ThatsAlok
          wrote on last edited by
          #4

          led mike wrote:

          If you cannot convert the library to a managed-mixed mode assembly

          any pointer to do that! i..e converting C++ Library to mixed mode assembly...?

          "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

          cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you

          L 1 Reply Last reply
          0
          • T ThatsAlok

            led mike wrote:

            If you cannot convert the library to a managed-mixed mode assembly

            any pointer to do that! i..e converting C++ Library to mixed mode assembly...?

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you

            L Offline
            L Offline
            led mike
            wrote on last edited by
            #5

            ThatsAlok wrote:

            any pointer to do that

            No but maybe Google[^] does :sigh: If you have the source for the project and the old project was a Visual Studio project then you just open it up in VS2005 and change the project settings to support the managed platform. There is more like #include's etc., all the information is available on msdn.com. I would also guess there is an Article here on Code Project. Even if you don't have an old VS project, as long as you have the source files you can create a project from scratch and add the source files to it.

            led mike

            1 Reply Last reply
            0
            • T ThatsAlok

              Dear All, i have a Unmanaged c++ based Library and i want to use it C#/C++ application(i.e. it expose some c based function .. ).. could some one give some pointer to use unmanaged library in c#/C++.. so that i don't have to provide some extra dll or lib with c#/C++ to my end user.... thanks in advance

              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

              cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Re

              K Offline
              K Offline
              kristmun
              wrote on last edited by
              #6

              I think that the cleanest way to access unmanaged functionality in .NET(c# or C++/CLI) is to write a wrapper in C++/CLI. There you will have an extra .dll, but you have bounded all unmanaged code within that .dll.

              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