Loading a mixed-mode assembly from unmanaged code

As the name says, I want to call a mixed-mode assembly from unmanaged code.

To be more precise, I want to dynamically load the mixed-mode assembly, and then execute some static unmanaged startup code that registers some managed C ++ Wrappers for C # code.

Is this possible (or do I need to implement .NET time or use COM?)?

Has anyone already done this and can share the experience?

PS: If the mixed-mode assembly contains a WPF window, will it start?

+3
source share
1 answer

CLR . , [ComVisible] CLR CorBindToRuntimeEx() - . DLL, ++/CLI thunk , CLR. , , .

ref class Bootstrap
{
public:
    static void Initialize() { 
        // etc..
    }
};

extern "C" __declspec(dllexport) 
void __stdcall LoadAndInitialize()
{
    Bootstrap::Initialize();
}

, . Marshal:: GetDelegateForFunctionPointer(). #pragma, .

+2

All Articles