Disapearing pointer


Here we call the constructor of the unmanaged DLL and then return the pointer back to the managed C# code. Within the constructor we initialize an another pointer to some class, thus we might be sure, that the pointer to this class will stil remain. Obviously it is not the case.

GerberLib.cpp: Gerber() with parameters
MaxRectsBinPack.cpp: MaxRectsBinPack(): binWidth(0), binHeight(0)
GerberLib.cpp: Gerber_New(): GerberPtr: 0117E8F0
GerberLib.cpp: Gerber_New(): MaxRectsBinPackPtr: 01118460
cppWrapperTest.cs: cppWrapper() hwndGerber: 0117E8F0
Form1Test.cs: bt_calculate_Click()
cppWrapperTest.cs: cswInsertBoards()
GerberLib.cpp: GetPossibleCustomerPanels(): ghw: 0117E8F0
Gerber.cpp: myGetListOfPossibleCustomerPanels(): MaxRectsBinPackPtr: 000000
Gerber.cpp: myGetListOfPossibleCustomerPanels(): number of single PCBs: 1

I suspect that the initialized variables also will be removed.

SOLUTION

Variables remains now. MaxRectsBinPackPtr remains now too. The solution was to remove double initialization of the MaxRectsBinPackPtr. The initialization of the MaxRectsBinPackPtr pointer happens in the constructor. The secondary initialization was included into the exported function being called from the managed code.


Leave a Reply

Your email address will not be published. Required fields are marked *