Managed and Unmanaged C

This is a discussion on Managed and Unmanaged C within the C# Programming forums, part of the General Programming Boards category; I'm writing a application in C# now. I have an DLL that was writed in Visual C++, ofcourse, unmanaged C++ ...

  1. #1
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807

    Managed and Unmanaged C

    I'm writing a application in C# now.
    I have an DLL that was writed in Visual C++, ofcourse, unmanaged C++ (Not .NET).

    How do I use this file in C#?
    All the functions on these DLL, needs Pointers and memory allocament, can't do this in C#, just if I configure them as Unsafe, and I don't want this.

    Thanks everybody.

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    You can write a Managed C++ Wrapper. Write a C++.NET DLL that implements your interface using garbage collection and .NET classes. This DLL can handle all the memory allocation and casting neccessary between the C# call to the C++.NET wrapper and the C++.NET call to the original DLL.

    If you have sourcecode of your dll, you can compile the unmanaged C++ source into the wrapper dll.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807

    Thumbs up Ok, I got the idea.

    Thanks for your help again

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. passing params between managed c++ and unmanaged c++
    By cechen in forum C++ Programming
    Replies: 11
    Last Post: 02-03-2009, 08:46 AM
  2. Call managed code (c#) from unmanaged code (VC++ 6.0)
    By playxn in forum C++ Programming
    Replies: 3
    Last Post: 10-14-2008, 01:11 PM
  3. instantiate unmanaged object in managed code
    By Redhead in forum C++ Programming
    Replies: 1
    Last Post: 01-11-2006, 07:43 AM
  4. Unmanaged C++ to Managed C++ Difficulties
    By pianorain in forum C# Programming
    Replies: 1
    Last Post: 09-02-2005, 11:12 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21