Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Calling DLL from Release/Debug exe

Calling DLL from Release/Debug exe

Scheduled Pinned Locked Moved C / C++ / MFC
c++debuggingquestionannouncement
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Steve Messer
    wrote on last edited by
    #1

    I have a wierd situation. I have a MFC based dialog application that loads dynamically an MFC dialog based dll. If I build the application in release mode and try to load the debug mode dll the application crashes. Likewise if I build the application in debug mode and load the release mode dll the application crashes. Any ideas why? Steve

    M 1 Reply Last reply
    0
    • S Steve Messer

      I have a wierd situation. I have a MFC based dialog application that loads dynamically an MFC dialog based dll. If I build the application in release mode and try to load the debug mode dll the application crashes. Likewise if I build the application in debug mode and load the release mode dll the application crashes. Any ideas why? Steve

      M Offline
      M Offline
      Mukkie
      wrote on last edited by
      #2

      Hello! Most probably (for sure) it is because of different memory allocators in release and debug version. Also, there might be problems with alignment (though I do not suspect that you have different alignment in debug and release). Does it work in both debug and both release? :)

      S 1 Reply Last reply
      0
      • M Mukkie

        Hello! Most probably (for sure) it is because of different memory allocators in release and debug version. Also, there might be problems with alignment (though I do not suspect that you have different alignment in debug and release). Does it work in both debug and both release? :)

        S Offline
        S Offline
        Steve Messer
        wrote on last edited by
        #3

        Yes, it works fine with either both in debug or both in release. Both make use of threads if that could have anything to do with it. What do you mean by different memory allocators? I will have to look into this alignment issue. I changed several things in the process of learning to get plug-ins working and everything else working as well. Oh, I am using a GDI+ header helper file that I believe I found on codeproject that does some strange things to fix some memory issues. Thanks, Steve #ifndef _GDIPLUSH_H_INCLUDED_ #define _GDIPLUSH_H_INCLUDED_ // // GDI+ helper file v1.0 // // Written by Zoltan Csizmadia (zoltan_csizmadia@yahoo.com) // // GDIPLUS_NO_AUTO_INIT: // GDI+ won't be initialized at program startup, // you have to create GdiPlus::GdiPlusInitialize object to // initialize GDI+ ( GDI+ will be uninitialized, when destructor // is called. #define GDIPLUS_NO_AUTO_INIT // GDIPLUS_USE_GDIPLUS_MEM: // GdipAlloc and GdipFree is used for memory operations // In this case _Crt functions cannot be used to detect // memory leaks //#define GDIPLUS_USE_GDIPLUS_MEM // GDIPLUS_NO_AUTO_NAMESPACE: // Gdiplus namespace wont' be defined as a used namespace // In this case you have to use Gdiplus:: prefix //#define GDIPLUS_NO_AUTO_NAMESPACE #ifdef _GDIPLUS_H #error Gdiplus.h is already included. You have to include this file instead. #endif // Fix for STL iterator problem #define iterator _iterator #define list _list #define map _map #define _GDIPLUSBASE_H namespace Gdiplus { namespace DllExports { #include "GdiplusMem.h" }; class GdiplusBase { public: #ifdef _DEBUG static void* __cdecl GdiplusAlloc( size_t nSize, LPCSTR szFileName, int nLine ) { #ifdef GDIPLUS_USE_GDIPLUS_MEM UNREFERENCED_PARAMETER(szFileName); UNREFERENCED_PARAMETER(nLine); return DllExports::GdipAlloc(nSize); #else return ::operator new( nSize, szFileName, nLine ); #endif } static void GdiplusFree( void* pVoid, LPCSTR szFileName, int nLine ) { #ifdef GDIPLUS_USE_GDIPLUS_MEM UNREFERENCED_PARAMETER(szFileName); UNREFERENCED_PARAMETER(nLine); DllExports::GdipFree(pVoid); #else ::operator delete( pVoid, szFileName, nLine ); #endif } void* (operator new)(size_t nSize) { return GdiplusAlloc( nSize, __FILE__, __LINE__ ); }

        M 1 Reply Last reply
        0
        • S Steve Messer

          Yes, it works fine with either both in debug or both in release. Both make use of threads if that could have anything to do with it. What do you mean by different memory allocators? I will have to look into this alignment issue. I changed several things in the process of learning to get plug-ins working and everything else working as well. Oh, I am using a GDI+ header helper file that I believe I found on codeproject that does some strange things to fix some memory issues. Thanks, Steve #ifndef _GDIPLUSH_H_INCLUDED_ #define _GDIPLUSH_H_INCLUDED_ // // GDI+ helper file v1.0 // // Written by Zoltan Csizmadia (zoltan_csizmadia@yahoo.com) // // GDIPLUS_NO_AUTO_INIT: // GDI+ won't be initialized at program startup, // you have to create GdiPlus::GdiPlusInitialize object to // initialize GDI+ ( GDI+ will be uninitialized, when destructor // is called. #define GDIPLUS_NO_AUTO_INIT // GDIPLUS_USE_GDIPLUS_MEM: // GdipAlloc and GdipFree is used for memory operations // In this case _Crt functions cannot be used to detect // memory leaks //#define GDIPLUS_USE_GDIPLUS_MEM // GDIPLUS_NO_AUTO_NAMESPACE: // Gdiplus namespace wont' be defined as a used namespace // In this case you have to use Gdiplus:: prefix //#define GDIPLUS_NO_AUTO_NAMESPACE #ifdef _GDIPLUS_H #error Gdiplus.h is already included. You have to include this file instead. #endif // Fix for STL iterator problem #define iterator _iterator #define list _list #define map _map #define _GDIPLUSBASE_H namespace Gdiplus { namespace DllExports { #include "GdiplusMem.h" }; class GdiplusBase { public: #ifdef _DEBUG static void* __cdecl GdiplusAlloc( size_t nSize, LPCSTR szFileName, int nLine ) { #ifdef GDIPLUS_USE_GDIPLUS_MEM UNREFERENCED_PARAMETER(szFileName); UNREFERENCED_PARAMETER(nLine); return DllExports::GdipAlloc(nSize); #else return ::operator new( nSize, szFileName, nLine ); #endif } static void GdiplusFree( void* pVoid, LPCSTR szFileName, int nLine ) { #ifdef GDIPLUS_USE_GDIPLUS_MEM UNREFERENCED_PARAMETER(szFileName); UNREFERENCED_PARAMETER(nLine); DllExports::GdipFree(pVoid); #else ::operator delete( pVoid, szFileName, nLine ); #endif } void* (operator new)(size_t nSize) { return GdiplusAlloc( nSize, __FILE__, __LINE__ ); }

          M Offline
          M Offline
          Mukkie
          wrote on last edited by
          #4

          Hello! "What do you mean by different memory allocators?" In debug build, memory allocator allocates for example guardians (additional bytes before and after allocated block of memory). Guardians are used to detect memory overwrites. Generally, there are a lot of differences between allocating memory in release and debug version. See msdn for more details :)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups