loading the classes in a native dll

hey guys,

i have a static linked native c++ dll i built.
i want to try and load the c++ classes in it, from an exe (for example). i want to be able to load these classes, and make objects and start using them.

im trying to implement a plugin system of some sort.

is that feasible i have done it using C# and the System.Reflection, but what about native C++
Since its done in the .NET framework, then its done C++, cause what im imagining the .NET was built on C++, so its there somewhere, maybe somebody could help me out please.

how r plugin systems implemented then

note: i know the idea of making interfaces, and the classes in the dll have to implement that interface, so i can call them easily,but how to load the dll dynamicly at run time and make object form it.

thx alot guys.


Answer this question

loading the classes in a native dll

  • CWGibbs

    no i meant statis lib not managed dll.

  • Mehmet Ozdemir

    There's no such thing as a static native DLL. You can either have a static lib or a DLL. If you have a DLL, you can use LoadLibrary and GetProcAddress to dynamically load and invoke exported functions. You cannot dynamically load a static lib - it's not intended to be used that way.

    egyptian_bean wrote:
    i dont want the /clr in anything, nor i want the reflection. all wat i have is a static NATIVE dll under Win32 and i want to be able to load it dynamically from a native exe.

    to be able to get the classes in it, so i can instanciate them!



  • Simba

    egyptian_bean wrote:
    no i meant statis lib not managed dll.

    /clr is not compatible with static libs. So you cannot create a managed static lib (as of VC++ 8). And you cannot reflect over native types, so what you would like to do is not possible.



  • D-S

    ok, so as i understood, i compile my code as static dll, and use the loadlibrary and getprocaddress to get the functions and so on.

    hm, ok thx for the help :D

  • Pete Lux

    i dont want the /clr in anything, nor i want the reflection. all wat i have is a static NATIVE dll under Win32 and i want to be able to load it dynamically from a native exe.

    to be able to get the classes in it, so i can instanciate them!

  • Karthikeyan K

    Nishant Sivakumar wrote:

    There's no such thing as a static native DLL. You can either have a static lib or a DLL. If you have a DLL, you can use LoadLibrary and GetProcAddress to dynamically load and invoke exported functions. You cannot dynamically load a static lib - it's not intended to be used that way.

    egyptian_bean wrote:

    I am experiencing the following issue:

    I want to dynamically load Native Message Defenition Library in managed C++.

    I am trying to load a Native Library developed in VC++ 6.0 using LoadLibrary() API.

    I need to get the Handle from the LoadLibrary API.When I call this LoadLibrary() API, I am gettin an exception "Can not return Marshal value".

    I want to pass this Handle as the second argument(ie.lpSource) in the FormatMessage().

    Here i have shown the way i have done the defenition to load Native Message Defenition Library in managed C++.

    [DllImport("Kernel32.dll" )]
    extern "C" IntPtr* LoadLibrary( String* IN_csLibName);

    In my code, exception occurs when I try to execute the below LoadLibrary() API.


    IntPtr* pHandle;

    pHandle = LoadLibrary(csLibPath);

    Note: Here csLibPath holds the correct path .

    In VC++ 6.0 it works fine, but in .Net I am facing the above mentioned problem.

    Please help me to find out a solution for my issue.


  • David Vertex Harris

    What do you mean by static DLL You mean a static lib, don't you

    Or if you actually mean a managed DLL written using C++/CLI, yes, you can use reflection on it (same as in C#).

    egyptian_bean wrote:
    hey guys,

    i have a static linked native c++ dll i built.
    i want to try and load the c++ classes in it, from an exe (for example). i want to be able to load these classes, and make objects and start using them.

    im trying to implement a plugin system of some sort.

    is that feasible i have done it using C# and the System.Reflection, but what about native C++
    Since its done in the .NET framework, then its done C++, cause what im imagining the .NET was built on C++, so its there somewhere, maybe somebody could help me out please.

    how r plugin systems implemented then

    note: i know the idea of making interfaces, and the classes in the dll have to implement that interface, so i can call them easily,but how to load the dll dynamicly at run time and make object form it.

    thx alot guys.



  • loading the classes in a native dll