none
EntryPointNotFoundException with DllImport when including third party header file RRS feed

  • General discussion

  • I have an issue with importing functions from a C++ DLL when I include a third party header file in my C++ DLL.


    --------------------------------------------Working Code--------------------------------------------------------------

    C++ Code

    #define LOGGER_EXPORT(T) extern "C" __declspec(dllexport) T __cdecl
    
    LOGGER_EXPORT(int) Logger_Test(){return 8;}
    


    C# Code

    [DllImport("BoostLogger.dll",
    EntryPoint = "Logger_Test",
    CallingConvention = CallingConvention.Cdecl)]
    public static extern int Logger_Test();
    
    try
    {
    int i = Logger_Test();
    }
    catch(EntryPointNotFoundException e) { }
    



    This example works without any issues, I am able to load the DLL and call into my test function.

    ----------------------------------Problem Code------------------------------------------------------------------------

    C++ Code

    #include <boost/log/sources/basic_logger.hpp>
    #include <boost/log/sinks/async_frontend.hpp>
    #include <boost/log/sinks/text_file_backend.hpp>
    #include <boost/log/sinks/debug_output_backend.hpp>
    
    #define LOGGER_EXPORT(T) extern "C" __declspec(dllexport) T __cdecl
    LOGGER_EXPORT(int) Logger_Test(){return 8;}
    


    C# Code

    [DllImport("BoostLogger.dll",
    EntryPoint = "Logger_Test",
    CallingConvention = CallingConvention.Cdecl)]
    public static extern int Logger_Test();
    
    try
    {
    int i = Logger_Test();
    }
    catch(EntryPointNotFoundException e) { }
    




    This throws a EntryPointNotFoundException when I try to call into my test function. Both projects build without any errors.
    I have checked the C++ dll with dependency walker and dumpbin and my function is being exported, yet I run into an error on the import.
    I don't see any option here to attach an image, or I would include a screen shot of the dumpbin and d-walker outputs.

    They both list the function as being export and the function name of Logger_Test, undecorated.


    Does anyone have any ideas of why including a header file would prevent me from importing a function that doesnt use it? I need to use a third party library in my project, but I could not find any documentation on such a limitation.

     

    Tuesday, March 1, 2011 11:00 PM