When are the constructor and the destructor of a Strategy executed?
Author: minourat
Creation Date: 8/11/2010 6:39 PM
profile picture

minourat

#1
When the Compile button is clicked, the following code gives an unhandled IO exception and then opens a dialog for sending debugging information to Microsoft.

CODE:
Please log in to see this code.


When the dialog box is closed, Wealth-Lab is terminated.
Which parts of the code are executed at the end of a compilation?
As a workaround, I moved the file opening and closing statements to Execute().
profile picture

DaveAronow

#2
I'd think the constructor is called after compiling finishes, this is how the strategy parameters are discovered and displayed. Does the path c:\tmp exist on your PC? Assuming it does it may be possible the constructor is being called twice and the result is that you can't access the file because it's already open by another process (in this case the other call).

If you want to figure out when/if they are called you should use logging to the event viewer (or some other method) inside a try/catch block to see what is going on.

Dave
profile picture

Eugene

#3
Don't use a destructor of the class.

I remember reporting 2 1/2 years ago that adding a destructor to a class that implements WealthScript will crash WL5. Crash will happen when compiling if constructor exists, or in runtime if a constructor doesn't exist.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).