{"record":{"id":"a53064e9a6adeeaf","repo":"dotnet/wpf","slug":"schemainvalidfortransport","errorCode":null,"errorMessage":"SchemaInvalidForTransport","messagePattern":"SchemaInvalidForTransport","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/IO/Packaging/PackWebRequest.cs","lineNumber":164,"sourceCode":"            }\n            \n            if (cachedPackageAvailable)\n            {\n#if DEBUG\n                if (PackWebRequestFactory._traceSwitch.Enabled)\n                    System.Diagnostics.Trace.TraceInformation(\n                        DateTime.Now.ToLongTimeString() + \" \" + DateTime.Now.Millisecond + \" \" +\n                        Environment.CurrentManagedThreadId + \": \" + \n                        \"PackWebRequest - Getting response from Package Cache\");\n#endif\n                return new PackWebResponse(_uri, _innerUri, _partName, _cacheEntry, _cachedPackageIsThreadSafe);\n            }\n            else\n            {\n                // only return a real WebRequest instance - throw on a PseudoWebRequest\n                WebRequest request = GetRequest(false);\n                if (_webRequest == null || _webRequest is PseudoWebRequest)\n                    throw new InvalidOperationException(SR.SchemaInvalidForTransport);\n\n#if DEBUG\n                if (PackWebRequestFactory._traceSwitch.Enabled)\n                    System.Diagnostics.Trace.TraceInformation(\n                        DateTime.Now.ToLongTimeString() + \" \" + DateTime.Now.Millisecond + \" \" +\n                        Environment.CurrentManagedThreadId + \": \" + \n                        \"PackWebRequest - Getting new response\");\n#endif\n                // Create a new response for every call\n                return new PackWebResponse(_uri, _innerUri, _partName, request);\n            }\n        }\n        #endregion\n\n        //------------------------------------------------------\n        //\n        //  Public Properties\n        //","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/IO/Packaging/PackWebRequest.cs#L146-L182","documentation":"PackWebRequest.GetResponse must return a real WebRequest, but for pack URIs that are fully resolvable in-process (the whole URI lives inside the pack scheme, e.g. application:///... with no container part), the request object is only a PseudoWebRequest. Since PseudoWebRequest cannot be handed to external code, GetResponse throws InvalidOperationException with SR.SchemaInvalidForTransport. This enforces that only transportable (real network-backed) requests escape the pack layer.","triggerScenarios":"Calling PackWebRequest.GetResponse (or exposing InnerResponse) for a pack URI that resolves to a PseudoWebRequest — i.e. a URI without a valid outer http:/file: transport component or a pack URI that is handled entirely in-memory.","commonSituations":"Reflection-based or generic WebRequest pipelines that call GetResponse() on WebRequest.Create(\"pack://application:,,,/page.xaml\") style URIs; code that assumes every WebRequest supports real transport.","solutions":["Resolve pack://application:/// resources through Application resource APIs (Application.LoadComponent, Application.GetResourceStream) instead of GetResponse.","Only call GetResponse on pack URIs with a real outer transport (e.g. pack://http:,...).","Inspect InnerResponse / use GetRequest(false) checks to detect PseudoWebRequest before calling GetResponse and fall back to resource APIs."],"exampleFix":"// before\nvar req = (PackWebRequest)WebRequest.Create(new Uri(\"pack://application:,,,/page.xaml\"));\nvar resp = req.GetResponse();\n// after\nvar s = Application.GetResourceStream(new Uri(\"page.xaml\", UriKind.Relative));","handlingStrategy":"type-guard","validationCode":"if (req is PackWebRequest pwr && pwr.InnerResponse is PseudoWebRequest)\n    // use Application.GetResourceStream / LoadComponent instead","typeGuard":"static bool IsTransportable(PackWebRequest r) => !(r.InnerResponse is PseudoWebRequest) && r.InnerResponse != null;","tryCatchPattern":"try { return req.GetResponse(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"transport\")) { return null; /* resolve via Application resource APIs */ }","preventionTips":["Use Application.GetResourceStream for pack://application:/// resources","Only call GetResponse on pack URIs with a real http/file outer part","Prefer GetResourceStream/LoadComponent over raw WebRequest for in-process resources"],"tags":["wpf","packaging","webrequest","invalid-operation"],"backgroundTag":"unsupported-operation","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"}