It is possible that Curve.JoinCurves returns null or an empty array. So, before you apply the [0] index operator, first check if the result is not null and has content:
Curve[] joined = Curve.JoinCurves(new Curve[] { curva1, union, corner_, curva2 }, 0.000000001, true);
Curve result = null;
if (null != joined && joined.Length > 0)
result = joined[0];
It starts to sound like a bug in Rhino or RhinoCommon to me. Does this happen with any curves in your code, or just a specific example?
One thing to check, if you haven’t done so already: are all the input curves 1) not null and 2) valid and 3) not short?
private bool CheckInput(IEnumerable<Curve> curvesUnion, double tolerance) {
foreach(Curve crv in curvesUnion)
{
if (null == crv)
{
RhinoApp.WriteLine("one of the curves is NULL");
return false;
}
String err;
if (!crv.IsValidWithLog(out err))
{
RhinoApp.WriteLine("One of the curves is not valid: "+err);
return false;
}
if (crv.IsShort(tolerance))
{
RhinoApp.WriteLine("one of the curves is too short");
return false;
}
}
}
This doesn’t make a whole lot of sense since debug and release builds are running against the exact same Rhino executable. One thing I notice from your screenshots is that it looks like you have a skin running in your release build and not in your debug build. What happens if you run your plug-in without the skin?