HandyOrg/HandyControl · error · NotSupportedException
Specified type ' ' is not supported.
Error message
Specified type '{0}' is not supported. What it means
PathSegmentHelper.Create attempts to build a PathSegmentImplementation for each known PathSegment subclass (LineSegment, PolyLineSegment, BezierSegment, PolyBezierSegment, QuadraticBezierSegment, PolyQuadraticBezierSegment, ArcSegment). If the supplied segment matches none of them, it throws NotSupportedException with the segment's type name inserted via ExceptionStringTable.TypeNotSupported.
Solutions
- Only use the built-in WPF segment types (LineSegment, PolyLineSegment, BezierSegment, PolyBezierSegment, QuadraticBezierSegment, PolyQuadraticBezierSegment, ArcSegment).
- Convert custom segments to an equivalent built-in type before passing to path helpers (e.g. approximate a custom curve with a PolyBezierSegment).
- Check segment types before calling Create and handle unsupported ones explicitly.
- Catch NotSupportedException and skip/log the unsupported segment instead of failing the whole path.
Example fix
// before
var impl = PathSegmentHelper.Create(myCustomSegment); // throws NotSupportedException
// after
PathSegment safeSegment = myCustomSegment is LineSegment || myCustomSegment is BezierSegment
? myCustomSegment
: new PolyLineSegment(); // or convert custom segment to a supported type
var impl = PathSegmentHelper.Create(safeSegment); Defensive patterns
Strategy: type-guard
Validate before calling
bool supported = seg is LineSegment || seg is PolyLineSegment || seg is BezierSegment || seg is PolyBezierSegment || seg is QuadraticBezierSegment || seg is PolyQuadraticBezierSegment || seg is ArcSegment;
if (!supported) throw new NotSupportedException($"{seg.GetType().Name} must be converted to a built-in segment."); Type guard
static bool IsSupportedSegment(PathSegment s) => s is LineSegment || s is PolyLineSegment || s is BezierSegment || s is PolyBezierSegment || s is QuadraticBezierSegment || s is PolyQuadraticBezierSegment || s is ArcSegment;
Try / catch
try { impl = PathSegmentHelper.Create(segment); }
catch (NotSupportedException ex) { Log.Warn(ex.Message); impl = null; /* skip segment */ } Prevention
- Only put built-in WPF PathSegment types into PathGeometry.Segments.
- Convert custom segment subclasses to Bezier/PolyLine approximations before helper calls.
- Add an IsSupportedSegment check when accepting geometry from external sources.
- Unit-test geometry deserialization paths for unknown segment types.
When it happens
Trigger: Passing a PathSegment that is not one of the seven supported WPF segment types — e.g. a custom PathSegment subclass or a null-derived unknown type — into PathSegmentHelper.Create(segment) or Create(segment, start).
Common situations: Custom geometry code where a user-defined PathSegment subclass was added to a PathGeometry; third-party geometry libraries producing their own segment types; geometry deserialization that produced unexpected segment instances.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- NotSupportedException
- NotSupportedException
- NotSupportedException
- NotSupportedException
- Can't call EndInit without first calling BeginInit.
AI-assisted analysis of HandyOrg/HandyControl@2c0875ebd6 (2026-09-14).
Data as JSON: /api/errors/5633bd4bcc638749.
Report an issue: GitHub.
Appendix: source
Thrown at src/Shared/Microsoft.Expression.Drawing/Drawing/PathSegmentHelper.cs:534
public abstract PathSegment ApplyTransform(GeneralTransform transform);
public static PathSegmentImplementation Create(PathSegment segment)
{
PathSegmentImplementation implementation;
if ((implementation = BezierSegmentImplementation.Create(segment as BezierSegment)) == null &&
(implementation = LineSegmentImplementation.Create(segment as LineSegment)) == null &&
(implementation = ArcSegmentImplementation.Create(segment as ArcSegment)) == null &&
(implementation = PolyLineSegmentImplementation.Create(segment as PolyLineSegment)) ==
null &&
(implementation = PolyBezierSegmentImplementation.Create(segment as PolyBezierSegment)) ==
null &&
(implementation =
QuadraticBezierSegmentImplementation.Create(segment as QuadraticBezierSegment)) ==
null &&
(implementation =
PolyQuadraticBezierSegmentImplementation.Create(segment as PolyQuadraticBezierSegment)
) == null)
throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture,
ExceptionStringTable.TypeNotSupported, new object[] { segment.GetType().FullName }));
return implementation;
}
public static PathSegmentImplementation Create(PathSegment segment, Point start)
{
var implementation = Create(segment);
implementation.Start = start;
return implementation;
}
public abstract void Flatten(IList<Point> points, double tolerance);
public abstract Point GetPoint(int index);
public abstract IEnumerable<SimpleSegment> GetSimpleSegments();
}
View on GitHub (pinned to 2c0875ebd6)