Creating .dll linked to Excel, add function error [modified]
-
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.
-
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.
-
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.
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
-
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
-
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
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 cannotdelete
a variable that was not created withnew
. Stack variables will be disposed of automatically when the function returns.I must get a clever new signature for 2011.