{"record":{"id":"415481503921f154","repo":"dotnet/wpf","slug":"sr-cursor-unsupportedformat-cursorfile","errorCode":null,"errorMessage":"SR.Cursor_UnsupportedFormat (cursorFile)","messagePattern":"SR\\.Cursor_UnsupportedFormat \\(cursorFile\\)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Cursor.cs","lineNumber":63,"sourceCode":"        /// Cursor from .ani or .cur file\n        /// </summary>\n        /// <param name=\"cursorFile\"></param>\n        /// <param name=\"scaleWithDpi\"></param>\n        public Cursor(string cursorFile, bool scaleWithDpi)\n        {\n            _scaleWithDpi = scaleWithDpi;\n            ArgumentNullException.ThrowIfNull(cursorFile);\n\n            if ((cursorFile != String.Empty) &&\n                (cursorFile.EndsWith(\".cur\", StringComparison.OrdinalIgnoreCase) ||\n                 cursorFile.EndsWith(\".ani\", StringComparison.OrdinalIgnoreCase)))\n            {\n                LoadFromFile(cursorFile);\n                _fileName = cursorFile;\n            }\n            else\n            {\n                throw new ArgumentException(SR.Format(SR.Cursor_UnsupportedFormat , cursorFile));\n            }\n        }\n\n        /// <summary>\n        /// Cursor from Stream\n        /// </summary>\n        /// <param name=\"cursorStream\"></param>\n        public Cursor(Stream cursorStream):this(cursorStream, false)\n        {\n        }\n\n        /// <summary>\n        /// Cursor from Stream\n        /// </summary>\n        /// <param name=\"cursorStream\"></param>\n        /// <param name=\"scaleWithDpi\"></param>\n        public Cursor(Stream cursorStream, bool scaleWithDpi)\n        {","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Cursor.cs#L45-L81","documentation":"The Cursor(string cursorFile) constructor requires the file to have a .cur or .ani extension (checked before LoadFromFile); any other extension throws ArgumentException (SR.Cursor_UnsupportedFormat) with the offending file name.","triggerScenarios":"new Cursor(@\"C:\\icons\\spinner.png\"), new Cursor(\"pointer.svg\"), or a path with no extension — anything not ending in .cur or .ani.","commonSituations":"Pointing the app at downloaded or design-team cursor assets in PNG/SVG/GIF format, or paths whose extension was stripped by a config transform.","solutions":["Convert the image to a genuine .cur or .ani file and pass that path.","Validate the extension with Path.GetExtension before constructing and show a clear user-facing message.","Ship known-good .cur/.ani assets as resources and load via Application.GetResourceStream instead of arbitrary files."],"exampleFix":"// before\nvar cursor = new Cursor(cursorPath); // cursorPath = \"spinner.png\"\n// after\nif (Path.GetExtension(cursorPath) is \".cur\" or \".ani\")\n    var cursor = new Cursor(cursorPath);\nelse\n    throw new InvalidOperationException($\"Cursor file must be .cur or .ani: {cursorPath}\");","handlingStrategy":"validation","validationCode":"var ext = Path.GetExtension(cursorFile);\nif (ext.Equals(\".cur\", StringComparison.OrdinalIgnoreCase) || ext.Equals(\".ani\", StringComparison.OrdinalIgnoreCase))\n    this.Cursor = new Cursor(cursorFile);","typeGuard":"static bool IsCursorFile(string p) => \".cur\".Equals(Path.GetExtension(p), StringComparison.OrdinalIgnoreCase) || \".ani\".Equals(Path.GetExtension(p), StringComparison.OrdinalIgnoreCase);","tryCatchPattern":"try { this.Cursor = new Cursor(cursorFile); } catch (ArgumentException ex) { /* fallback to Cursors.Arrow and report unsupported format */ }","preventionTips":["Check the extension is .cur or .ani before constructing","Convert PNG/SVG assets to .cur/.ani at build time","Verify File.Exists in addition to extension to avoid downstream file errors"],"tags":["wpf","cursor","file-format"],"backgroundTag":"unsupported-config-value","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}