A simple solution is to AddRef both of these collections in the unit operation constructor.
The initial reference count in an earlier version of the wizard was 1 on COM objects. I have changed that to zero, so that they can be immediately assigned to smart pointers, without tricks like Attach. A quick scan on your objects: this will be a problem for the objects (materials, parameters) that you add to the collections (the collection in your project does not keep a reference count on its members).
So the nicer solution: switch to the new collection object generated by the wizard. And use COMSmartPtr objects instead of direct pointers.
I see you commented out the AddRef in the get_parameters and get_ports; this will surely lead to a crash as well. They will be Released() by the software that makes the call.
May I suggest you generate a new project with the wizard? If you add a unit operation to the project, it will ask you to generate a unit operation frame-work. This will be nicer than what you have now, a much better starting point. The collection issues will be solved. There is example code on how to create ports and parameters in the generated unit operation code. Validate will be partially implemented. And I do not think re-doing your Calculate is a lot of work (compared to fixing what you have now).Statistics: Posted by jasper — 08 July 2015, 14:11
]]>