SixLabors/ImageSharp · error · NotSupportedException
Newly created value for tag
Error message
Newly created value for tag {tag} is null. What it means
ExifProfile.SetValueInternal could not create a new ExifValue for the requested EXIF tag: ExifValues.Create(tag) returned null, meaning the tag has no known type metadata in ImageSharp's EXIF tables, so a NotSupportedException is thrown rather than silently adding an unusable value.
Solutions
- Only set values for tags ImageSharp supports; check support by ensuring ExifValues.Create-equivalent lookup succeeds, or first read the profile to see which tags exist.
- For custom tags, add the value to the profile at the raw-data level or via a supported generic tag type instead of SetValue.
- Upgrade ImageSharp — newer versions extend the supported EXIF tag table.
Example fix
// before
profile.SetValue((ExifTagValue)0x9C9B, "MyData"); // unsupported custom tag -> throws
// after
if (profile.TryGetValue((ExifTagValue)0x9C9B, out _))
{
profile.SetValue((ExifTagValue)0x9C9B, "MyData");
}
else
{
// handle unsupported tag: skip or store elsewhere
} Defensive patterns
Strategy: try-catch
Validate before calling
// Only call SetValue for tags the profile already exposes or that are known-supported
bool tagWritable(ExifProfile profile, ExifTagValue tag) =>
profile.TryGetValue(tag, out _) || Enum.IsDefined(typeof(ExifTagValue), tag); // plus known-supported check Try / catch
try { profile.SetValue(tag, value); }
catch (NotSupportedException ex)
{ /* unsupported tag: skip, log, or persist metadata by other means */ } Prevention
- Restrict EXIF writes to tags listed by ImageSharp's ExifTag constants.
- Check that a profile entry exists (TryGetValue) before setting custom tags.
- Keep ImageSharp updated so newly specified EXIF tags become writable.
When it happens
Trigger: Calling ExifProfile.SetValue(tag, value) with a tag not present in the profile and not in ExifValues' supported tag table — e.g. custom/manufacturer-specific tags or a numeric (ExifTagValue) tag with no registered ExifValue factory.
Common situations: Writing maker-note or non-standard EXIF tags that ImageSharp doesn't model; typos in tag constants; trying to write tags added in newer EXIF specs than the library supports.
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
- Data type is not supported.
- Source ICC profile is missing.
- Target ICC profile is missing.
- ICC conversion supports at most four input and output…
- Invalid calculation type
AI-assisted analysis of SixLabors/ImageSharp@59ce6af6fc (2026-09-13).
Data as JSON: /api/errors/df91c72a9291efa0.
Report an issue: GitHub.
Appendix: source
Thrown at src/ImageSharp/Metadata/Profiles/Exif/ExifProfile.cs:288
/// <summary>
/// Sets the value of the specified tag.
/// </summary>
/// <param name="tag">The tag of the Exif value.</param>
/// <param name="value">The value.</param>
/// <exception cref="NotSupportedException">The newly created value is null.</exception>
internal void SetValueInternal(ExifTag tag, object? value)
{
foreach (IExifValue exifValue in this.Values)
{
if (exifValue.Tag == tag)
{
exifValue.TrySetValue(value);
return;
}
}
ExifValue? newExifValue = ExifValues.Create(tag) ?? throw new NotSupportedException($"Newly created value for tag {tag} is null.");
newExifValue.TrySetValue(value);
this.values.Add(newExifValue);
}
/// <summary>
/// Synchronizes the profiles with the specified metadata.
/// </summary>
/// <param name="metadata">The metadata.</param>
internal void Sync(ImageMetadata metadata)
{
this.SyncResolution(ExifTag.XResolution, metadata.HorizontalResolution);
this.SyncResolution(ExifTag.YResolution, metadata.VerticalResolution);
}
internal void SyncDimensions(int width, int height)
{
if (this.TryGetValue(ExifTag.PixelXDimension, out _))View on GitHub (pinned to 59ce6af6fc)