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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Creating .dll linked to Excel, add function error [modified]

Creating .dll linked to Excel, add function error [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 Posts 3 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
    jharn
    wrote on last edited by
    #1

    Gentlemen, I hope everyone is having a good day. I have an problem with my .dll that is linked to Excel. I have 2 functions in the file, they are named in the def file and they work fine. I added a third this morning, added name to def file. I declared it in VBE. For some reason, when I try to type it into a cell and give it a variable, i.e. cell formula is =Hs_P(B8), immediately Excel has an error and shuts down. I am very perplexed. Any ideas? Have I given enough information? This is the error Excel is throwing out "Excel asertion error" And the line from the code _ASSERTE(_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)); I haven't found the problem, but I believe it is the way I am calling one function from inside of another function.

    L 1 Reply Last reply
    0
    • J jharn

      Gentlemen, I hope everyone is having a good day. I have an problem with my .dll that is linked to Excel. I have 2 functions in the file, they are named in the def file and they work fine. I added a third this morning, added name to def file. I declared it in VBE. For some reason, when I try to type it into a cell and give it a variable, i.e. cell formula is =Hs_P(B8), immediately Excel has an error and shuts down. I am very perplexed. Any ideas? Have I given enough information? This is the error Excel is throwing out "Excel asertion error" And the line from the code _ASSERTE(_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)); I haven't found the problem, but I believe it is the way I am calling one function from inside of another function.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Assuming you are talking about some C++ code then you may need to use your debugger to find exactly where it is failing. From the information provided above you have an invalid pointer somewhere.

      I must get a clever new signature for 2011.

      J 1 Reply Last reply
      0
      • L Lost User

        Assuming you are talking about some C++ code then you may need to use your debugger to find exactly where it is failing. From the information provided above you have an invalid pointer somewhere.

        I must get a clever new signature for 2011.

        J Offline
        J Offline
        jharn
        wrote on last edited by
        #3

        This function seems to be causing the assertion failure, but I cannot se why, it compiles without error. I think I found the error, it appears I cannot delete the arrays before I return x, does anyone know this to be true? delete [] J0; delete [] n0; delete [] Ir; delete [] Jr; delete [] nr; return(x); }

        modified on Thursday, January 27, 2011 5:35 PM

        T L 2 Replies Last reply
        0
        • J jharn

          This function seems to be causing the assertion failure, but I cannot se why, it compiles without error. I think I found the error, it appears I cannot delete the arrays before I return x, does anyone know this to be true? delete [] J0; delete [] n0; delete [] Ir; delete [] Jr; delete [] nr; return(x); }

          modified on Thursday, January 27, 2011 5:35 PM

          T Offline
          T Offline
          T2102
          wrote on last edited by
          #4

          You can't create any memory errors or access violations without destabilizing Excel.

          1 Reply Last reply
          0
          • J jharn

            This function seems to be causing the assertion failure, but I cannot se why, it compiles without error. I think I found the error, it appears I cannot delete the arrays before I return x, does anyone know this to be true? delete [] J0; delete [] n0; delete [] Ir; delete [] Jr; delete [] nr; return(x); }

            modified on Thursday, January 27, 2011 5:35 PM

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Having looked at the code in your original message I see the problem. You are instantiating your arrays on the stack by statements such as:

            double J0[10] = {0, 1, -5, -4, -3, -2, -1, 2, 3};

            and then trying to dispose of them by delete. This is the cause of your problem, you cannot delete a variable that was not created with new. Stack variables will be disposed of automatically when the function returns.

            I must get a clever new signature for 2011.

            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