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;
    SumSurface sumSurface = SumSurface.Create(crv, rail);
    Brep brep1;
    if (sumSurface == null)
      Component.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Curve extrusion failed");
      brep1 = (Brep) null;
      Brep brep2 = sumSurface.ToBrep();
      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: (5.3 KB)

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.