{"record":{"id":"13c6349cc82bf466","repo":"dotnet/wpf","slug":"sr-getresponsefailed","errorCode":null,"errorMessage":"SR.GetResponseFailed","messagePattern":"SR\\.GetResponseFailed","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/XmlDataProvider.cs","lineNumber":570,"sourceCode":"\n            XmlDocument doc = new XmlDocument();\n            Exception ex = null;\n            // request the content from the URI\n            try\n            {\n                if (isExtendedTraceEnabled)\n                {\n                    TraceData.TraceAndNotify(TraceEventType.Warning,\n                                        TraceData.XmlLoadSource(\n                                            TraceData.Identify(this),\n                                            Dispatcher.CheckAccess() ? \"synchronous\" : \"asynchronous\",\n                                            TraceData.Identify(request.RequestUri.ToString())));\n                }\n\n                WebResponse response = WpfWebRequestHelper.GetResponse(request);\n                if (response == null)\n                {\n                    throw new InvalidOperationException(SR.GetResponseFailed);\n                }\n\n                // Get Stream and content type from WebResponse.\n                Stream stream = response.GetResponseStream();\n\n                if (isExtendedTraceEnabled)\n                {\n                    TraceData.TraceAndNotify(TraceEventType.Warning,\n                                        TraceData.XmlLoadDoc(\n                                            TraceData.Identify(this)));\n                }\n\n                // load the XML from the stream\n                doc.Load(stream);\n                stream.Close();\n            }\n            catch (Exception e)\n            {","sourceCodeStart":552,"sourceCodeEnd":588,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/XmlDataProvider.cs#L552-L588","documentation":"XmlDataProvider.CreateDocFromExternalSource performs an HTTP request for the XML document and expects WpfWebRequestHelper.GetResponse to return a non-null WebResponse. If the response comes back null (the request failed to yield a usable response), the provider throws an InvalidOperationException with SR.GetResponseFailed while loading the data source.","triggerScenarios":"XmlDataProvider.Source pointing at an HTTP/HTTPS URL whose request completes without a usable response object; synchronous LoadFromSource or asynchronous CreateDocFromExternalSourceAsynch path during BeginInit/Initialize.","commonSituations":"XML file served from a web server that is down or misbehaving; proxy/firewall interference; server returning an empty or aborted response; network outage in CI environments.","solutions":["Verify the URI in XmlDataProvider.Source is reachable (curl/Invoke-WebRequest the URL).","Check network connectivity, proxy settings, and that the server actually returns a response body.","Prefer a local file path for Source when the XML is available on disk instead of fetching over HTTP.","Wrap provider initialization in error handling and surface the original request URI (see TraceData output) to diagnose."],"exampleFix":"// before\nprovider.Source = new Uri(\"http://internal-server/data.xml\");\n// after\n// verify reachability first, or fall back to local copy\nprovider.Source = File.Exists(localPath)\n    ? new Uri(localPath, UriKind.Absolute)\n    : new Uri(\"https://validated-server/data.xml\");","handlingStrategy":"try-catch","validationCode":"using var client = new HttpClient();\nbool reachable = false;\ntry { reachable = (await client.GetAsync(uri)).IsSuccessStatusCode; } catch { reachable = false; }","typeGuard":null,"tryCatchPattern":"try { provider.BeginInit(); provider.Source = uri; provider.EndInit(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"GetResponse\")) { log.Error(\"XML source request returned no response: \" + uri, ex); }","preventionTips":["Test the XML source URL with a simple HTTP probe before binding.","Use local file paths where possible instead of HTTP URIs.","Check proxy/firewall configuration in deployment environments.","Handle the provider's DataChanged/Errors events to surface load failures."],"tags":["wpf","network","http","xml"],"backgroundTag":"http-request-failed","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"}