{"record":{"id":"aa1841604d05cac4","repo":"dotnet/wpf","slug":"sr-requestalreadystarted","errorCode":null,"errorMessage":"SR.RequestAlreadyStarted","messagePattern":"SR\\.RequestAlreadyStarted","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/IO/Packaging/ByteRangeDownloader.cs","lineNumber":302,"sourceCode":"        #region Internal Properties\n\n        /// <summary>\n        /// Proxy for all requests to ByteRangeDownloader\n        /// </summary>\n        internal IWebProxy Proxy\n        {\n            set\n            {\n                CheckDisposed();\n                ArgumentNullException.ThrowIfNull(value);\n\n                if (!_firstRequestMade)\n                {\n                    _proxy = value;\n                }\n                else    // Once first request is made it cannot change\n                {\n                    throw new InvalidOperationException(SR.RequestAlreadyStarted);\n                }\n            }\n        }\n\n        /// <summary>\n        /// Authentication information for all requests to ByteRangeDownloader\n        /// </summary>\n        internal ICredentials Credentials\n        {\n            set\n            {\n                CheckDisposed();\n                _credentials = value;\n            }\n        }\n\n        /// <summary>\n        /// Cache Policy for all requests to ByteRangeDownloader","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/IO/Packaging/ByteRangeDownloader.cs#L284-L320","documentation":"The ByteRangeDownloader.Proxy property is immutable once the first HTTP request has been made (_firstRequestMade). Setting Proxy afterwards throws InvalidOperationException(SR.RequestAlreadyStarted) because the download pipeline is already configured and running.","triggerScenarios":"Assigning downloader.Proxy after a prior RequestByteRanges call has kicked off the first request.","commonSituations":"Reconfiguring a downloader mid-download, or reusing a cached downloader instance across requests with different proxy settings.","solutions":["Set Proxy immediately after construction, before any RequestByteRanges call","Create a new ByteRangeDownloader instance if the proxy must change","Serialize configuration: gather all settings first, then start downloading"],"exampleFix":"// before\nvar d = new ByteRangeDownloader(uri, handle, temp);\nd.RequestByteRanges(ranges);\nd.Proxy = newProxy; // throws\n// after\nvar d = new ByteRangeDownloader(uri, handle, temp);\nd.Proxy = newProxy; // before first request\nd.RequestByteRanges(ranges);","handlingStrategy":"validation","validationCode":"if (!proxyConfigured && firstRequestAlreadyMade)\n    throw new InvalidOperationException(\"Set Proxy before starting downloads\");\n// configure before first RequestByteRanges call","typeGuard":null,"tryCatchPattern":"try {\n    downloader.Proxy = newProxy;\n} catch (InvalidOperationException ex) when (ex.Message.Contains(\"Request\")) {\n    downloader = new ByteRangeDownloader(uri, handle, tempFile) { Proxy = newProxy };\n}","preventionTips":["Configure all downloader properties immediately after construction","Never reuse a downloader across logically distinct downloads needing different settings","Centralize downloader setup in one place before download starts"],"tags":["wpf","packaging","invalid-operation","lifecycle"],"backgroundTag":"invalid-state-transition","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"}