{"record":{"id":"d2c6054b000f4e8c","repo":"dotnet/wpf","slug":"sr-nonpacksooabsoluteurinotallowed","errorCode":null,"errorMessage":"SR.NonPackSooAbsoluteUriNotAllowed","messagePattern":"SR\\.NonPackSooAbsoluteUriNotAllowed","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs","lineNumber":646,"sourceCode":"        /// or  pack Uri, \"pack://siteoforigin:,,,/foo.jpg\"\n        ///\n        /// </summary>\n        /// <param name=\"uriRemote\">the uri maps to the resource</param>\n        /// <returns>PackagePart or null</returns>\n        public static StreamResourceInfo GetRemoteStream(Uri uriRemote)\n        {\n            SiteOfOriginPart sooPart = null;\n\n            ArgumentNullException.ThrowIfNull(uriRemote);\n\n            if (uriRemote.OriginalString == null)\n                throw new ArgumentException(SR.Format(SR.ArgumentPropertyMustNotBeNull, \"uriRemote\", \"OriginalString\"));\n\n            if (uriRemote.IsAbsoluteUri)\n            {\n                if (!BaseUriHelper.SiteOfOriginBaseUri.IsBaseOf(uriRemote))\n                {\n                    throw new ArgumentException(SR.NonPackSooAbsoluteUriNotAllowed);\n                }\n            }\n\n            Uri resolvedUri = BindUriHelper.GetResolvedUri(BaseUriHelper.SiteOfOriginBaseUri, uriRemote);\n\n            Uri packageUri = PackUriHelper.GetPackageUri(resolvedUri);\n            Uri partUri = PackUriHelper.GetPartUri(resolvedUri);\n\n            //\n            // SiteOfOriginContainer must have been added into the package cache, the code should just\n            // take use of that SiteOfOriginContainer instance, instead of creating a new instance here.\n            //\n            SiteOfOriginContainer sooContainer = (SiteOfOriginContainer)GetResourcePackage(packageUri);\n\n            // the SiteOfOriginContainer is shared across threads;  synchronize access to it\n            // using the same lock object as other uses (PackWebResponse+CachedResponse.GetResponseStream)\n            lock (sooContainer)\n            {","sourceCodeStart":628,"sourceCodeEnd":664,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs#L628-L664","documentation":"GetRemoteStream loads files from the site of origin — the location the application was deployed from. Absolute URIs passed to it must fall under the pack siteoforigin base (pack://siteoforigin:,,,). Any other absolute URI (http://, file://, pack://application:,,,) is rejected with ArgumentException because the API cannot treat it as a site-of-origin resource.","triggerScenarios":"Calling Application.GetRemoteStream with an absolute Uri not based on pack://siteoforigin:,,, — e.g. new Uri(\"http://server/file.jpg\"), new Uri(\"file:///C:/x.jpg\"), or a pack://application:,,, URI (which belongs to GetContentStream).","commonSituations":"Mixing up GetContentStream (pack application) and GetRemoteStream (pack siteoforigin); passing web URLs expecting the API to download files; ClickOnce apps where loose files resolve via siteoforigin but the code passes a file:// path.","solutions":["Use a pack://siteoforigin:,,,/filename URI or a relative Uri for deployed loose files","For compiled-in resources, call GetContentStream with pack://application:,,, instead","For arbitrary URLs, use HttpClient/WebClient rather than GetRemoteStream","Check BaseUriHelper.SiteOfOriginBaseUri.IsBaseOf(uri) before calling to validate"],"exampleFix":"// before\nvar s = Application.GetRemoteStream(new Uri(\"http://cdn.example.com/config.xml\"));\n// after\nvar s = Application.GetRemoteStream(new Uri(\"pack://siteoforigin:,,,/config.xml\"));","handlingStrategy":"validation","validationCode":"bool isSooUri(Uri u) => !u.IsAbsoluteUri || BaseUriHelper.SiteOfOriginBaseUri.IsBaseOf(u);","typeGuard":"bool IsValidRemoteUri(Uri u) => u is not null && (!u.IsAbsoluteUri || (u.Scheme == Uri.UriSchemePack && u.AbsoluteUri.StartsWith(\"pack://siteoforigin\")));","tryCatchPattern":"try { var s = Application.GetRemoteStream(uri); } catch (ArgumentException ex) { /* use pack://siteoforigin or HttpClient */ }","preventionTips":["Use pack://siteoforigin:,,, URIs for deployed loose files","Use GetContentStream for compiled-in resources","Use HttpClient for arbitrary web URLs","Check BaseUriHelper.SiteOfOriginBaseUri.IsBaseOf before calling"],"tags":["wpf","uri","pack-uri","siteoforigin","argument"],"backgroundTag":"invalid-url-format","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"}