Error while trying to create Brep Extrude C#

Hey Guys,
I am trying to extrude a polyline profile along a line.

Here is the Code

private void RunScript(Polyline iPoly, Line iLine, ref object A)
  {

    Curve iRiser = (Curve) null;
    GH_Convert.ToCurve_Primary(iLine, ref iRiser);

    Curve iProfile = (Curve) null;
    GH_Convert.ToCurve_Primary(iPoly, ref iProfile);
    
    A = Extrude(iProfile, iRiser);

    

  }

  // <Custom additional code> 
  public Brep Extrude(Curve crv, Curve rail)
  {
    Vector3d translationVector = crv.PointAtStart - rail.PointAtStart;
    rail.Translate(translationVector);
    SumSurface sumSurface = SumSurface.Create(crv, rail);
    Brep brep1;
    if (sumSurface == null)
    {
      Component.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Curve extrusion failed");
      brep1 = (Brep) null;
    }
    else
    {
      Brep brep2 = sumSurface.ToBrep();
      brep2.Faces.SplitKinkyFaces();
      brep1 = brep2;
    }
    return brep1;
  }

  // </Custom additional code> 
}

Even though I convert the Polyline and Line to Curve, the function still throws errors.
Can someone tell me what exactly am I doing wrong.

Here is the Grasshopper script: ExtrudeError.gh (5.3 KB)

Hello.
How about ToNurbscurve()?ToNurbscurve

@11159 , Thanks a lot. This works.
But I Still wonder, what was the issue in my code. It seemed correct to me to convert them to Curve.