You have to write a mixed-mode DLL in C++ ( I don't think you can use
any other language, but I may be wrong here). I've done this before. The
mixed-mode DLL exports a pure C interface, and the C functions are
calling into the managed interface using Managed C++ (or C++/CLI once
VC++ 2005 is out).
extern "C"
{
__declspec(dllexport) bool __stdcall Convert([...])
// unmanaged function exported from the DLL
{
try
{
[...] just write your managed code here
return true;
}
catch(...)
{
}
return false;
}
}
You just have to solve the data marshalling, converting managed arrays
to unmanaged, and so on. It depends what you want to pass to the
function and what you want to return. For example, managed data can be
pinned and the pinned pointer passed to an unmanaged function:
MemoryStream __gc* managed_stream = new MemoryStream;
[...]
unsigned char managed_array __gc[] = managed_stream->GetBuffer();
unsigned char __pin* ptr = &managed_array[0];
unmanaged_callback(ptr, static_cast<unsigned>(managed_stream->Length));
You could be more specific if you have trouble with a certain detail.
Tom
Marty wrote:
Hi,
I have this DLL made with VB.NET made as a Class Library project. I
know this is managed code.
I have my other made with VC++.NET, unmanaged code.
The point is that I want to use function within my DLL in the VC++ project.
I've been reading document over the internet and this
http://msdn.microsoft.com/msdnmag/is...A/default.aspx
but I can't find a tutorial explaining how to integrate and use my
VB.NET DLL in VC++. There is text that says that I should import the
DLL content but it is not clear for me.
Does any of you would have a good reference to suggest to me?
I appreciate, thank you
Marty