dotnet/wpf · error · InvalidOperationException
SR.GetResponseFailed
Error message
SR.GetResponseFailed
What it means
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.
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.
Example fix
// before
provider.Source = new Uri("http://internal-server/data.xml");
// after
// verify reachability first, or fall back to local copy
provider.Source = File.Exists(localPath)
? new Uri(localPath, UriKind.Absolute)
: new Uri("https://validated-server/data.xml"); Defensive patterns
Strategy: try-catch
Validate before calling
using var client = new HttpClient();
bool reachable = false;
try { reachable = (await client.GetAsync(uri)).IsSuccessStatusCode; } catch { reachable = false; } Try / catch
try { provider.BeginInit(); provider.Source = uri; provider.EndInit(); }
catch (InvalidOperationException ex) when (ex.Message.Contains("GetResponse")) { log.Error("XML source request returned no response: " + uri, ex); } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- " }} " element found. Expected fixed page element ( }} ).
- errMsg (dynamic: message of caught…
- FileFormatException(new Uri(_reader.BaseURI…
- GetResponseFailed (requestUri)
- PrintSchemaTags.Framework.PrintTicketRoot +…
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/13c6349cc82bf466.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/XmlDataProvider.cs:570
XmlDocument doc = new XmlDocument();
Exception ex = null;
// request the content from the URI
try
{
if (isExtendedTraceEnabled)
{
TraceData.TraceAndNotify(TraceEventType.Warning,
TraceData.XmlLoadSource(
TraceData.Identify(this),
Dispatcher.CheckAccess() ? "synchronous" : "asynchronous",
TraceData.Identify(request.RequestUri.ToString())));
}
WebResponse response = WpfWebRequestHelper.GetResponse(request);
if (response == null)
{
throw new InvalidOperationException(SR.GetResponseFailed);
}
// Get Stream and content type from WebResponse.
Stream stream = response.GetResponseStream();
if (isExtendedTraceEnabled)
{
TraceData.TraceAndNotify(TraceEventType.Warning,
TraceData.XmlLoadDoc(
TraceData.Identify(this)));
}
// load the XML from the stream
doc.Load(stream);
stream.Close();
}
catch (Exception e)
{View on GitHub (pinned to 81131a70a4)