Yesterday I had to fix a simple still subtle bug in TableDifference, I think sharing the experience will be useful for everybody involved in custom component creation.
The component has some fields that are initialized in the component constructor, at the end of the work the component does not clear them as I would expect the object to be destroyed by the SSIS engine. Everything works fine until you run the component in a data flow task contained in a foreach loop then... bang! the component crash.
The problem is that the component was not fresh-built but contained properties with the same data that were there at the end of its first execution. It seems to me that SSIS does not destroy components after a data flow terminates but reuses them during the subsequent runs of the same data flow task recalling their pre-execute method. I solved the problem clearing variable values in the pre-execute method, the problem is solved but I don't like the way the SSIS engine works, I would really like an object to be destroyed and then recreated when the container data flow task finishes execution.
If confirmed (is anybody from Microsoft listening?) this behaviour is - in my opinion - very interesting but wrong. You can decide to use this behaviour to implement some sort of state management in a component but in the same time you are prone to very nasty bugs if you do not clear all your properties in the pre-execute method and then initialize them to a meaningful value.
I did not found useful documentation about this behaviour, has anybody done any kind of investigation about it?