I solve a similar problem like this:
delegate void tempFunc();
//the function that the delegate instance actually points to
void libCoin3D::CenterballDragger::memberCallback()
{
....
}
//the function that the unmanaged code will call and pass data to
void __stdcall intermediateCallback( void * userData, SoDragger *dragger)
{
using System::Runtime::InteropServices::GCHandle;
GCHandle gch = GCHandle::FromIntPtr((System::IntPtr)userData);
tempFunc^ tF = (tempFunc^)gch.Target;
tF();
gch.Free(); // If the call only once, otherwise it is necessary to keep the pointer and delete it later
}
tempFunc^ tF = gcnew tempFunc(this, &libCoin3D::CenterballDragger::memberCallback);
// pass to unmanaged code
setCallback( &intermediateCallback, (void*)GCHandle::ToIntPtr(GCHandle::Alloc(tF)) );