It could be that I’m just dense and this was readily apparent to everyone else, but I’ll post this anyway for the sake of community. For those of you who would like to know how to use Visual Studio to debug your custom dll, do the following – I’ll use the example of the ExpertSample.dll that comes with MT4.
After getting the sample up and running, do the following:
1. Setup your sampledll.mqh file to point directly to your DEBUG library file (C:blah\experts\samples\DLLSample\Debug\ExpertSample.dll)
2. If you just try to just select Debug from the VS IDE, you will be asked to select an EXE file. DON’T do this. If you did go ahead and select terminal.exe as the exe, the whole process simply exits and the debugger won’t catch anything. Maybe someone smarter than me can explain why..
3. But, to really be able to debug your DLL, you have to attach to the terminal.exe process explicitly from VS. Go to Debug, Processes and select your terminal .exe process. Now, the debugger will start, and you can set breakpoints, etc.
It is really the combination of using the correct DLL that VS has source access to and attaching to the running terminal process that does the trick.
Categories: MT4 Tips
No Comments »