I have seen this issue mentioned here and there, especially by 7bit, but I was never able to get around this problem:
The strategy tester does not properly decrement the reference count of the loaded library during deinit(). Because of this, the DLL file stays loaded in the system, and crashes when you attempt to run the tester again.
I tried to use GetModuleHandle() and FreeLibrary(), but that did not seem to solve the problem.
CORRECTION:
dll_handle returns a non-0 number, and FreeLibrary decrements it.
If I check GetModuleHandle() again, I get 0 - which should mean the library is unloaded.
However if I start the tester again it still crashes.
This is getting pretty annoying because I cannot use the optimization feature.
What exactly happens? Is it that the DLL's global variables remain initialized and polluted by the last run's data? Or does an error occur during the attempt to initialize a DLL over an already-initialized DLL?
The strategy tester does not properly decrement the reference count of the loaded library during deinit(). Because of this, the DLL file stays loaded in the system, and crashes when you attempt to run the tester again.
I tried to use GetModuleHandle() and FreeLibrary(), but that did not seem to solve the problem.
Inserted Code
if (IsTesting()) { int dll_handle = DLLHandle("C:\Program Files (x86)\MT\experts\libraries\SQLBridgeV2.dll"); Print(dll_handle); if (dll_handle>0) FreeLibrary(dll_handle); }
dll_handle returns a non-0 number, and FreeLibrary decrements it.
If I check GetModuleHandle() again, I get 0 - which should mean the library is unloaded.
However if I start the tester again it still crashes.
This is getting pretty annoying because I cannot use the optimization feature.
What exactly happens? Is it that the DLL's global variables remain initialized and polluted by the last run's data? Or does an error occur during the attempt to initialize a DLL over an already-initialized DLL?