Allocating memory in a .NET C++ DLL

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've created a .NET DLL using Visual Studio 2003 which will be referenced by a C# program. I'm able to link the two together just fine now and make calls. The problem is I need the DLL to allocate memory and pass it back to the C# program.

I can't see to use either new or malloc inside that DLL though as the normal libraries aren't compiled in. Sorry if this is a FAQ, but I'd definitely appreciate it if someone can help me work this out.
 
Are you using managed or unmanaged C++? How are you calling the
functions from C#?



Mattias
 
I created a .NET class library, which says it's using managed extension for C++. I only chose that one because I'm calling from C#, which is .NET, so it seemed to make sense. If there's a better choice I'm happy to switch.

From my C# program I'm doing a [DllImport ("")] of each of my functions. Right now they're each their own functions. I'd really rather the C++ library expose a class that I can call from C#, but I've no idea how to do that yet.
 
The need for this just disappeared. I finally have everything working from C# directly.
 
Back
Top