{"record":{"id":"cb30110d12f5bbd5","repo":"dotnet/wpf","slug":"sr-media-unknownchanneltype","errorCode":null,"errorMessage":"SR.Media_UnknownChannelType","messagePattern":"SR\\.Media_UnknownChannelType","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaPlayer.cs","lineNumber":801,"sourceCode":"            )\n        {\n            bool    notifyUceDirectly = false;\n\n            //\n            // Check what sort of channel type we have, we do quite different\n            // things depending on what the channel type is.\n            //\n            switch(channel.MarshalType)\n            {\n                case ChannelMarshalType.ChannelMarshalTypeSameThread:\n                    break;\n\n                case ChannelMarshalType.ChannelMarshalTypeCrossThread:\n                    notifyUceDirectly = true;\n                    break;\n\n                default:\n                    throw new System.NotSupportedException(SR.Media_UnknownChannelType);\n            }\n\n            //\n            // If we aren't going to notify the Uce directly, then we need to register for a\n            // frame update.\n            //\n            if (!notifyUceDirectly)\n            {\n                if (null == _newFrameHandler)\n                {\n                    _newFrameHandler = new EventHandler(OnNewFrame);\n\n                    _mediaPlayerState.NewFrame += _newFrameHandler;\n                }\n            }\n            else\n            {\n                if (null != _newFrameHandler)","sourceCodeStart":783,"sourceCodeEnd":819,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaPlayer.cs#L783-L819","documentation":"MediaPlayer's internal resource update (UpdateResourceInternal) inspects the channel marshal type of the media's DUCE channel and only supports SameThread and CrossThread marshaling. Any other value means the media infrastructure is in an unknown/internal-only state, so the library throws NotSupportedException. This is an internal invariant violation, not something user code should be able to trigger through normal APIs.","triggerScenarios":"Calling APIs that force a resource update (e.g. rendering a MediaPlayer visual, MediaElement playing media) when the underlying channel marshal type is neither ChannelMarshalTypeSameThread nor ChannelMarshalTypeCrossThread - typically only under a custom or corrupted media transport.","commonSituations":"Custom/media-harness test transports, windowed rendering in unusual hosting scenarios (e.g. remote/terminal sessions without MIL availability), or WPF internal bugs where the transport reports an unexpected marshal type.","solutions":["Report/log this as a WPF internals bug; verify with a plain MediaElement/MediaPlayer in a default WPF app to rule out environment-specific transport issues","Ensure the media system is started normally (media played through MediaElement/MediaPlayer on a UI thread with a working dispatcher)","Update to a newer .NET/WPF runtime where MIL/transport fixes may be included"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (MediaSystem.IsTransportConnected || mediaTransport == null) log.Warn(\"unexpected media transport state before resource update\");","typeGuard":"bool HasKnownMarshalType(ChannelMarshalType t) => t == ChannelMarshalType.ChannelMarshalTypeSameThread || t == ChannelMarshalType.ChannelMarshalTypeCrossThread;","tryCatchPattern":"try { player.UpdateResource(); } catch (NotSupportedException ex) when (ex.Message.Contains(\"ChannelType\")) { LogInternalInvariantFailure(ex); }","preventionTips":["Use standard MediaElement/MediaPlayer APIs on a normal UI thread","Avoid custom media transports/harnesses in production","Track WPF runtime updates for MIL/media transport fixes"],"tags":["wpf","media","internal-invariant"],"backgroundTag":"internal-invariant-violation","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"}