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. Debug Assertion Failed when calling dll function

Debug Assertion Failed when calling dll function

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialdebugginghelpquestion
6 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.
  • J Offline
    J Offline
    Jordan C Atlas
    wrote on last edited by
    #1

    Hello, I am using managed code to call a function in an unmanaged DLL. When I call the function, the program runs until the end of the function, and then gives a "Debug Assertion Failed!" dialog box for "Expression: _CrtIsValidHeapPoint(pUserData)". The error occurs no matter what code I have inside the function. For example, removing all the code in the dll function, so that it's just an empty function, does not prevent the error. The only thing that I've done to prevent the error is to comment out the line that calls the dll function. This is how I import the function: // Set up the import [DllImportAttribute("lib.dll")] extern "C" int func(string inputFileName); This is the function declaration in the DLL code: __declspec(dllexport) int func(string inputFileName) Does anyone have any suggestions for how to track this down? Thanks, --Jordan -- modified at 13:10 Friday 20th January, 2006

    C 1 Reply Last reply
    0
    • J Jordan C Atlas

      Hello, I am using managed code to call a function in an unmanaged DLL. When I call the function, the program runs until the end of the function, and then gives a "Debug Assertion Failed!" dialog box for "Expression: _CrtIsValidHeapPoint(pUserData)". The error occurs no matter what code I have inside the function. For example, removing all the code in the dll function, so that it's just an empty function, does not prevent the error. The only thing that I've done to prevent the error is to comment out the line that calls the dll function. This is how I import the function: // Set up the import [DllImportAttribute("lib.dll")] extern "C" int func(string inputFileName); This is the function declaration in the DLL code: __declspec(dllexport) int func(string inputFileName) Does anyone have any suggestions for how to track this down? Thanks, --Jordan -- modified at 13:10 Friday 20th January, 2006

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      what does the DLL's exported function look like ? Cleek | Image Toolkits | Thumbnail maker

      J 1 Reply Last reply
      0
      • C Chris Losinger

        what does the DLL's exported function look like ? Cleek | Image Toolkits | Thumbnail maker

        J Offline
        J Offline
        Jordan C Atlas
        wrote on last edited by
        #3

        Even if I remove the whole function body, I get the same error. So, right now it looks like this: __declspec(dllexport) int func(string inputFileName) { } -- modified at 13:10 Friday 20th January, 2006

        C 1 Reply Last reply
        0
        • J Jordan C Atlas

          Even if I remove the whole function body, I get the same error. So, right now it looks like this: __declspec(dllexport) int func(string inputFileName) { } -- modified at 13:10 Friday 20th January, 2006

          C Offline
          C Offline
          Chris Losinger
          wrote on last edited by
          #4

          so, you're exporting a function that takes a std::string as input ? i suspect then that the std string ctor is going to be called even if there isn't any code in the body of the function. that could be related to the problem. what if you change that to:

          __declspec(dllexport) int func(const char *inputFileName)
          {
          }

          ? Cleek | Image Toolkits | Thumbnail maker -- modified at 13:15 Friday 20th January, 2006

          J 1 Reply Last reply
          0
          • C Chris Losinger

            so, you're exporting a function that takes a std::string as input ? i suspect then that the std string ctor is going to be called even if there isn't any code in the body of the function. that could be related to the problem. what if you change that to:

            __declspec(dllexport) int func(const char *inputFileName)
            {
            }

            ? Cleek | Image Toolkits | Thumbnail maker -- modified at 13:15 Friday 20th January, 2006

            J Offline
            J Offline
            Jordan C Atlas
            wrote on last edited by
            #5

            Yes! That fixed it. Thanks. So it's not allowed to create a managed function that uses an unmanaged class as input? --Jordan

            C 1 Reply Last reply
            0
            • J Jordan C Atlas

              Yes! That fixed it. Thanks. So it's not allowed to create a managed function that uses an unmanaged class as input? --Jordan

              C Offline
              C Offline
              Chris Losinger
              wrote on last edited by
              #6

              Jordan C. Atlas wrote:

              So it's not allowed to create a managed function that uses an unmanaged class as input?

              i wish i could answer that... but i really don't know. :) glad my suggestion helped, though. Cleek | Image Toolkits | Thumbnail maker

              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