HandyOrg/HandyControl · error · Exception
InteropMethods.Gdip.StatusException(status)
Error message
InteropMethods.Gdip.StatusException(status)
What it means
GifImage.CreateSourceFromFile calls GdipCreateBitmapFromFile and throws the GDI+ StatusException when the native call returns a non-Ok status. This wraps a GDI+ error code (e.g. InvalidParameter, FileNotFound, OutOfMemory) into a managed exception while creating a GIF image from a file path. It indicates the file could not be loaded as a bitmap by GDI+.
Solutions
- Verify the file exists at the resolved full path (Path.GetFullPath) before loading
- Confirm the file is a valid, supported image format
- Check file read permissions and that the file is not locked by another process
- Wrap the image creation in try-catch and fall back to a placeholder image
Example fix
// before
var gif = new GifImage { Source = path }; // throws if bad
// after
var full = Path.GetFullPath(path);
if (!File.Exists(full)) throw new FileNotFoundException(full);
var gif = new GifImage { Source = full }; Defensive patterns
Strategy: try-catch
Validate before calling
if (!File.Exists(Path.GetFullPath(path))) throw new FileNotFoundException(path);
Try / catch
try { return GifImage.CreateSourceFromFile(path); } catch (Exception ex) when (ex.Message.Contains("Gdip")) { return PlaceholderImage; } Prevention
- Resolve and verify paths before load
- Checksum untrusted image files
- Use pack URIs for embedded assets
When it happens
Trigger: Calling GifImage with a Source path that does not exist, is locked, is not a valid image, or when the native GDI+ flat API returns an error status from GdipCreateBitmapFromFile.
Common situations: Typo or wrong working directory for a relative GIF path; file corrupted or unsupported format; file moved/deleted after build (pack vs filesystem confusion); permissions issues.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- StatusException(InteropMethods.Gdip.OutOfMemory)
- StatusException(status)
- stream null
- NativeHandle0
- GdiplusInvalidSize
AI-assisted analysis of HandyOrg/HandyControl@2c0875ebd6 (2026-09-14).
Data as JSON: /api/errors/d69901956f4669dc.
Report an issue: GitHub.
Appendix: source
Thrown at src/Shared/HandyControl_Shared/Controls/Image/GifImage.cs:150
}
catch
{
// ignored
}
finally
{
NativeImage = IntPtr.Zero;
}
}
private void CreateSourceFromFile(string filename)
{
filename = Path.GetFullPath(filename);
var status = InteropMethods.Gdip.GdipCreateBitmapFromFile(filename, out var bitmap);
if (status != InteropMethods.Gdip.Ok)
throw InteropMethods.Gdip.StatusException(status);
status = InteropMethods.Gdip.GdipImageForceValidation(new HandleRef(null, bitmap));
if (status != InteropMethods.Gdip.Ok)
{
InteropMethods.Gdip.GdipDisposeImage(new HandleRef(null, bitmap));
throw InteropMethods.Gdip.StatusException(status);
}
SetNativeImage(bitmap);
EnsureSave(this, filename, null);
}
private void CreateSourceFromStream(Stream stream)
{
if (stream == null)
throw new ArgumentException("stream null");View on GitHub (pinned to 2c0875ebd6)