Dynamic plugins: destructor doesn't get called?


I have some ‘cleanup’ code in the destructor of my dynamic plugin. When I use tonfilm’s way of debugging Writting plug-in iin C-sharp and set a breakpoint in the destructor, it doesn’t seem to ever get there (a breakpoint in Evaluate() correctly suspends execution).

How can I make sure everything gets correctly cleaned up when a patch is closed or the node gets deleted?


you need to have your plugin class also implementing IDisposable, so when the plugin gets deleted this will call the Dispose method.

Destructors in c# are called on garbage collection so there is no way to know whenever they will be called.