{"record":{"id":"b0a5598460fa9165","repo":"dotnet/wpf","slug":"webresponsepartnotfound","errorCode":null,"errorMessage":"WebResponsePartNotFound","messagePattern":"WebResponsePartNotFound","errorType":"exception","errorClass":"WebException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/IO/Packaging/PackWebResponse.cs","lineNumber":233,"sourceCode":"                    // wrap our stream for efficiency (short reads are expanded)\n                    _responseStream = new BufferedStream(_responseStream);\n                }\n\n                // handle degenerate case where there is no part name\n                if (_partName == null)\n                {\n                    _fullStreamLength = streamLength;    // entire container\n                    _mimeType = WpfWebRequestHelper.GetContentType(_fullResponse);\n\n                    // pass this so that ResponseStream holds a reference to us until the stream is closed\n                    _responseStream = new ResponseStream(_responseStream, this);\n                }\n                else\n                {\n                    // open container on netStream\n                    Package c = Package.Open(_responseStream);\n                    if (!c.PartExists(_partName))\n                        throw new WebException(SR.WebResponsePartNotFound);\n\n                    PackagePart p = c.GetPart(_partName);\n\n                    Stream s = p.GetSeekableStream(FileMode.Open, FileAccess.Read);\n\n                    _mimeType = new MS.Internal.ContentType(p.ContentType);      // save this for use in ContentType property - may still be null\n                    _fullStreamLength = s.Length;   // just this stream\n\n                    // Wrap in a ResponseStream so that this container will be released\n                    // when the stream is closed\n                    _responseStream = new ResponseStream(s, this, _responseStream, c);\n                }\n\n                // length available? (-1 means the server chose not to report it)\n                if (_fullStreamLength >= 0)\n                {\n                    _lengthAvailable = true;\n                }","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/IO/Packaging/PackWebResponse.cs#L215-L251","documentation":"When a PackWebResponse is backed by a network stream (the pack URI had an outer http/file transport), GetResponseStream opens the downloaded container and looks up the requested part name. If the container has no part matching _partName, it throws WebException(SR.WebResponsePartNotFound). The same check underlies the ContentType and ContentLength properties, so accessing those on a missing part also fails.","triggerScenarios":"Requesting a pack URI whose referenced part does not exist inside the downloaded package, then calling GetResponseStream, ContentType, or ContentLength.","commonSituations":"Typos or case mismatches in the part path after pack://http:...; server package updated/renamed while client still requests an old part name; wrong content-type-derived part name in a nested package.","solutions":["Verify the part exists: Package.Open(stream) then c.PartExists(partName) before consuming the response.","Correct the part name in the pack URI (it must match the package's part paths exactly, including case and extension).","Check that the server actually serves the expected package version containing the part."],"exampleFix":"// before\nvar s = resp.GetResponseStream();\n// after\nusing (Package c = Package.Open(resp.GetResponseStream()))\n    if (!c.PartExists(packUri part)) throw ... // or choose another part","handlingStrategy":"try-catch","validationCode":"using (Package c = Package.Open(stream))\n    bool exists = c.PartExists(new Uri(partName, UriKind.Relative));","typeGuard":null,"tryCatchPattern":"try { return resp.GetResponseStream(); }\ncatch (WebException ex) when (ex.Message.Contains(\"part\")) { /* part missing: check URI/part name or package version */ throw; }","preventionTips":["Verify part names against the actual package before requesting","Match part path case exactly","Keep client pack URIs in sync with the served package version"],"tags":["wpf","packaging","not-found","webresponse"],"backgroundTag":"resource-not-found","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"}