(C#) Intersection curve: crash when using Insert3DSketch

Hi, I'm trying to get an intersection curve between a plane and a surface. Reading the API docs, I tried to use Insert3DSketch but everytime I try to use it Solidworks crashes without notice.

I also tried to register a macro in order to see the commands. The macro works fine.

I'm trying with this code:

swDoc = ((ModelDoc2)(swApp.ActiveDoc));

Body2 myBody = (Body2)bo;

swSelectionManager.AddSelectionListObject(myReferencePlane, selData);

swDoc.SketchManager.InsertSketch(true);

swDoc.Sketch3DIntersections();

swSelectionManager.AddSelectionListObject(myBody, selData);

swDoc.Sketch3DIntersections();

swDoc.ClearSelection2(true);

swDoc.Sketch3DIntersections();

swDoc.ClearSelection2(true);

swDoc.SketchManager.InsertSketch(true);

Thanks.

SolidworksApi macros