Need example of C++ interop from a flat dll api calling a .NET managed module

  • Thread starter Thread starter Donald Hess
  • Start date Start date
D

Donald Hess

Guest
Request:

I am looking for an example online of how to call a .NET managed component library from a C++ CLI/CLR dll unmanaged flat API function.


Background:

I know how to use pInvoke and make a .NET object a COM object and use it in C++. However I need to make a flat API dll that calls a managed .NET object that is NOT COM based. (This will go on IIS server and has to scale.)

This is my unmanaged dll call:


__declspec(dllexport) MyFlatAPIRater(int x, float f, char* message, int messageSize)
{
System::Text::String^ messageManaged = MyMarshalByteToSB(message, messageSize);

ManagedAPIRaterNamespace::MyManagedRater^ rater = gcnew ManagedAPIRaterNamespace::MyManagedRater(x, f, messageManaged);

rater.doRate();

//results get written to flat file for now. no output from dll directly.
}



I built the x86 dll without issues. However whenever I try to use dependency walker, it just locks up.


I read there are issues with the DllMain(HInstance hInstance, DWORD dwReason, LPVOID) when the DLL_PROCESS_ATTACH is called due to managed libraries initializing. However there was no mention of the appropriate fix.

Continue reading...
 
Back
Top