{"record":{"id":"8810461b3bebe6a3","repo":"dotnet/wpf","slug":"getresponsefailed-requesturi","errorCode":null,"errorMessage":"GetResponseFailed (requestUri)","messagePattern":"GetResponseFailed \\(requestUri\\)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/WpfWebRequestHelper.cs","lineNumber":226,"sourceCode":"        WebRequest request = CreateRequest(uri);\n        return GetResponse(request);\n    }\n\n    internal static WebResponse GetResponse(WebRequest request)\n    {\n        WebResponse response = request.GetResponse();\n        \n        // 'is' is used here instead of exact type checks to allow for the (remote) possibility that an internal\n        // implementation type derived from HttpWebRequest/Response may be used by System.Net.\n        if (response is HttpWebResponse && !(request is HttpWebRequest))\n            throw new ArgumentException();\n        \n        // It is not clear whether WebRequest.GetRespone() can ever return null, but some of the v1 code had\n        // this check, so it is added here just in case.\n        if (response == null)\n        {\n            Uri requestUri = BaseUriHelper.PackAppBaseUri.MakeRelativeUri(request.RequestUri);\n            throw new IOException(SR.Format(SR.GetResponseFailed, requestUri.ToString()));\n        }\n        \n        HandleWebResponse(response);\n        return response;\n    }\n    internal static WebResponse EndGetResponse(WebRequest request, IAsyncResult ar)\n    {\n        WebResponse response = request.EndGetResponse(ar);\n        if (response is HttpWebResponse && !(request is HttpWebRequest))\n            throw new ArgumentException();\n        // It is not clear whether WebRequest.GetRespone() can ever return null, but some of the v1 code had\n        // this check, so it is added here just in case.\n        if (response == null)\n        {\n            Uri requestUri = BaseUriHelper.PackAppBaseUri.MakeRelativeUri(request.RequestUri);\n            throw new IOException(SR.Format(SR.GetResponseFailed, requestUri.ToString()));\n        }\n        HandleWebResponse(response);","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/WpfWebRequestHelper.cs#L208-L244","documentation":"WpfWebRequestHelper.GetResponse throws IOException with SR.GetResponseFailed when the underlying WebRequest returns a null WebResponse. Since it is unclear whether WebRequest.GetResponse can ever return null, this is a defensive check carried over from v1 code; the message embeds the request URI relative to the pack application base.","triggerScenarios":"Calling CreateRequestAndGetResponse (or the response-consuming path) where the underlying WebRequest.GetResponse() returns null, e.g. for scheme handlers that fail silently.","commonSituations":"Loading application resources when the pack web-request pipeline returns no response, often downstream of a malformed URI or an aborted request.","solutions":["Catch IOException around resource-loading calls and inspect the embedded requestUri to identify the failing resource.","Verify the resource URI is valid and the resource exists (pack://application:,,,/... with correct assembly/component syntax).","Check inner/logged WebExceptions from the underlying request for the root cause."],"exampleFix":"// before\nvar resp = WpfWebRequestHelper.CreateRequestAndGetResponse(request);\n// after\ntry { var resp = WpfWebRequestHelper.CreateRequestAndGetResponse(request); }\ncatch (IOException ex) { log.Error(\"Resource load failed: \" + uri, ex); throw; }","handlingStrategy":"try-catch","validationCode":"if (request == null || request.RequestUri == null)\n    throw new InvalidOperationException(\"Request and RequestUri must be set before calling GetResponse.\");","typeGuard":null,"tryCatchPattern":"try { var resp = WpfWebRequestHelper.CreateRequestAndGetResponse(request); }\ncatch (IOException ex)\n{ throw new InvalidOperationException(\"Resource load failed: \" + request.RequestUri, ex); }","preventionTips":["Validate resource URIs before requesting.","Log the failing URI from the exception message to pinpoint the resource.","Check for underlying WebExceptions indicating the real failure cause."],"tags":["io-exception","wpf","resource-loading","null-response","network"],"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"}