{"record":{"id":"b8afaf7b26a79e24","repo":"stride3d/stride","slug":"value-cannot-be-null-parameter-uri","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'uri')","messagePattern":"Value cannot be null\\. \\(Parameter 'uri'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Wpf/Extensions/ImageExtensions.cs","lineNumber":19,"sourceCode":"// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)\n// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.\n\nusing System;\nusing System.Windows.Controls;\nusing System.Windows.Media;\nusing System.Windows.Media.Imaging;\nusing Stride.Core.Annotations;\n\nnamespace Stride.Core.Presentation.Extensions\n{\n    public static class ImageExtensions\n    {\n        public static void SetSource([NotNull] this Image image, [NotNull] Uri uri)\n        {\n            if (image == null)\n                throw new ArgumentNullException(nameof(image));\n            if (uri == null)\n                throw new ArgumentNullException(nameof(uri));\n\n            image.Source = ImageSourceFromFile(uri);\n        }\n\n        public static void SetSource([NotNull] this Image image, [NotNull] string uri)\n        {\n            if (string.IsNullOrWhiteSpace(uri))\n                throw new ArgumentException(\"Invalid 'uri' argument.\");\n\n            SetSource(image, new Uri(uri));\n        }\n\n        [NotNull]\n        public static ImageSource ImageSourceFromFile([NotNull] Uri uri)\n        {\n            if (uri == null)\n                throw new ArgumentNullException(nameof(uri));\n","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/Extensions/ImageExtensions.cs#L1-L37","documentation":"ImageExtensions.SetSource(this Image, string) delegates to the Uri overload after converting the string, and throws ArgumentNullException when the uri string is null. The null check for uri precedes the conversion to a Uri object.","triggerScenarios":"Calling image.SetSource(null) with a string argument, or passing a null value coming from a binding/view-model property that represents the image path.","commonSituations":"Bound path property is null because data context is not yet set; configuration/app-resource for the image path is missing; database or model record has a null image path field.","solutions":["Check string.IsNullOrWhiteSpace before calling SetSource and skip or use a placeholder image.","Initialize the bound path property to a valid default URI.","Fix the upstream data source so the image path is never null.","Coalesce to a fallback asset: SetSource(uri ?? DefaultImageUri)."],"exampleFix":"// before\nlogo.SetSource(item.ImagePath); // ImagePath may be null\n// after\nif (!string.IsNullOrWhiteSpace(item.ImagePath))\n    logo.SetSource(item.ImagePath);","handlingStrategy":"validation","validationCode":"if (!string.IsNullOrWhiteSpace(imagePath))\n    image.SetSource(imagePath);","typeGuard":"static bool HasImageSource(string path) => !string.IsNullOrWhiteSpace(path);","tryCatchPattern":"try { image.SetSource(imagePath); }\ncatch (ArgumentNullException) { image.Source = null; }","preventionTips":["Initialize path properties to valid defaults","Treat null path as 'no image' explicitly in view-models","Validate configuration/resource paths at startup"],"tags":["wpf","argumentnull","image","uri"],"backgroundTag":"null-argument","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}