dotnet/wpf · error · NotSupportedException

SR.Media_UnknownChannelType

Error message

SR.Media_UnknownChannelType

What it means

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.

Solutions

  1. 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
  2. Ensure the media system is started normally (media played through MediaElement/MediaPlayer on a UI thread with a working dispatcher)
  3. Update to a newer .NET/WPF runtime where MIL/transport fixes may be included
Defensive patterns

Strategy: try-catch

Validate before calling

if (MediaSystem.IsTransportConnected || mediaTransport == null) log.Warn("unexpected media transport state before resource update");

Type guard

bool HasKnownMarshalType(ChannelMarshalType t) => t == ChannelMarshalType.ChannelMarshalTypeSameThread || t == ChannelMarshalType.ChannelMarshalTypeCrossThread;

Try / catch

try { player.UpdateResource(); } catch (NotSupportedException ex) when (ex.Message.Contains("ChannelType")) { LogInternalInvariantFailure(ex); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/cb30110d12f5bbd5. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaPlayer.cs:801

            )
        {
            bool    notifyUceDirectly = false;

            //
            // Check what sort of channel type we have, we do quite different
            // things depending on what the channel type is.
            //
            switch(channel.MarshalType)
            {
                case ChannelMarshalType.ChannelMarshalTypeSameThread:
                    break;

                case ChannelMarshalType.ChannelMarshalTypeCrossThread:
                    notifyUceDirectly = true;
                    break;

                default:
                    throw new System.NotSupportedException(SR.Media_UnknownChannelType);
            }

            //
            // If we aren't going to notify the Uce directly, then we need to register for a
            // frame update.
            //
            if (!notifyUceDirectly)
            {
                if (null == _newFrameHandler)
                {
                    _newFrameHandler = new EventHandler(OnNewFrame);

                    _mediaPlayerState.NewFrame += _newFrameHandler;
                }
            }
            else
            {
                if (null != _newFrameHandler)

View on GitHub (pinned to 81131a70a4)