C# Wrapper into unmanged code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jason

    #1

    C# Wrapper into unmanged code

    Hello

    I've got a DLL that is written in C++ and I want to create a C# wrapper for
    it, instead of using Pinvoke. I know this can be done, but I'm not sure how
    to go about this. I've got VS 2005 and I've been looking on the net, but
    not alot of clear definitions out there. For now, until I get he hang of it,
    my c++ DLL is pretty basic, as it only has functions that take in and return
    integers.

    Can anyone provide an example, or point to a good place on the web?

    Thanks


  • =?Utf-8?B?UGV0ZXIgUml0Y2hpZSBbQyMgTVZQXQ==?=

    #2
    RE: C# Wrapper into unmanged code

    You'll have to use PInvoke to get at the C++ code from your C# wrapper.

    If your C++ Dll has C++ classes in it, you won't be able to PInvoke them.

    I suggest you write a managed wrapper in C++/CLI. C++/CLI uses C++ Interop
    (or Implicit PInvoke) and wouldn't require that you manually PInvoke. This
    is especially useful if you want to use a native C++ class in C#.

    --
    Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.

    Microsoft MVP, Visual Developer - Visual C#


    "Jason" wrote:
    Hello
    >
    I've got a DLL that is written in C++ and I want to create a C# wrapper for
    it, instead of using Pinvoke. I know this can be done, but I'm not sure how
    to go about this. I've got VS 2005 and I've been looking on the net, but
    not alot of clear definitions out there. For now, until I get he hang of it,
    my c++ DLL is pretty basic, as it only has functions that take in and return
    integers.
    >
    Can anyone provide an example, or point to a good place on the web?
    >
    Thanks
    >
    >
    >

    Comment

    • Jason

      #3
      Re: C# Wrapper into unmanged code

      Thats what I was think I would need to do, write a managed wrapper in C++
      but I'm not sure how to accomplisj that. Is there a good example that you
      can point out?
      "Peter Ritchie [C# MVP]" <PRSoCo@newsgro ups.nospamwrote in message
      news:31993116-7FE7-4107-B784-034615DFCCA3@mi crosoft.com...
      You'll have to use PInvoke to get at the C++ code from your C# wrapper.
      >
      If your C++ Dll has C++ classes in it, you won't be able to PInvoke them.
      >
      I suggest you write a managed wrapper in C++/CLI. C++/CLI uses C++
      Interop
      (or Implicit PInvoke) and wouldn't require that you manually PInvoke.
      This
      is especially useful if you want to use a native C++ class in C#.
      >
      --
      Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.

      Microsoft MVP, Visual Developer - Visual C#
      >
      >
      "Jason" wrote:
      >
      >Hello
      >>
      >I've got a DLL that is written in C++ and I want to create a C# wrapper
      >for
      >it, instead of using Pinvoke. I know this can be done, but I'm not sure
      >how
      >to go about this. I've got VS 2005 and I've been looking on the net, but
      >not alot of clear definitions out there. For now, until I get he hang of
      >it,
      >my c++ DLL is pretty basic, as it only has functions that take in and
      >return
      >integers.
      >>
      >Can anyone provide an example, or point to a good place on the web?
      >>
      >Thanks
      >>
      >>
      >>

      Comment

      • Leon Lambert

        #4
        Re: C# Wrapper into unmanged code

        I use IJW to interface my C# applications to unmanaged C++ DLLS. It
        involves making a managed C++ interface assembly though. Doing it this
        way the C++ can expose entire classes and their methods and not just C
        style methods. I find it really easy to do. Following is a link that
        helps to understand how to use IJW.


        Hope this helps
        Leon Lambert

        Jason wrote:
        Hello
        >
        I've got a DLL that is written in C++ and I want to create a C# wrapper for
        it, instead of using Pinvoke. I know this can be done, but I'm not sure how
        to go about this. I've got VS 2005 and I've been looking on the net, but
        not alot of clear definitions out there. For now, until I get he hang of it,
        my c++ DLL is pretty basic, as it only has functions that take in and return
        integers.
        >
        Can anyone provide an example, or point to a good place on the web?
        >
        Thanks
        >
        >

        Comment

        Working...