Bei Windows-Anwendungen bleibt die Miracast-Bildschirmspiegelung nach dem erneuten Verbinden im Status „Verbinden“ hängen.

GOLF 0 Zuverlässigkeitspunkte
2026-04-13T13:12:51.5666667+00:00

Ich entwickle eine Windows-basierte Anwendung, die die Miracast-Beispielkomponenten von Microsoft (AdvancedCasting und BasicMediaCasting) integriert. Ich versuche, eine automatische Wiederverbindung nach Verbindungsabbruch zu implementieren. Das Problem ist, dass die Statusverwaltung der Verbindung völlig unzuverlässig ist – selbst wenn das Gerät die Verbindung erfolgreich wiederherstellt, bleibt der Status manchmal bei „Verbinden“ hängen, anstatt korrekt aktualisiert zu werden. Dies verursacht erhebliche Probleme in unserer Demo-Umgebung, da die Anwendung während der Vorführungen fehlerhaft erscheint, und ich kann die Ursache für die fehlerhafte Statussynchronisierung nicht finden. Gibt es eine zuverlässige Möglichkeit, die korrekte Aktualisierung des Miracast-Übertragungsstatus sicherzustellen, insbesondere bei programmatischer Wiederverbindung?

Windows für Unternehmen | Windows Server | Geräte und Bereitstellung | Konfigurieren von Anwendungsgruppen
0 Kommentare Keine Kommentare

2 Antworten

Sortieren nach: Am hilfreichsten
  1. VPHAN 44,940 Zuverlässigkeitspunkte Unabhängiger Berater
    2026-04-13T17:55:06.5733333+00:00

    Hi GOLF,

    The synchronization failure you are seeing stems from the way the Windows.Media.Casting stack handles state transitions within the underlying Wi-Fi Direct and RTSP layers. When a programmatic reconnection is triggered too rapidly, the CastingConnection object often fails to transition fully to a terminal Disconnected state, leaving the State property stuck in an intermediate phase that the UI incorrectly interprets as an active or pending connection. This is typically caused by residual handles in the media projection engine that do not clear until the original object is completely destroyed and the transport layer acknowledges the tear-down.

    To fix this for your demo environment, you must implement a strict "dispose and recreate" pattern rather than attempting to recycle the existing connection. Before initiating a reconnection, you need to call DisconnectAsync and immediately unregister all StateChanged and ErrorOccurred event handlers to prevent them from firing against a stale object. Once the handlers are removed, set your CastingConnection instance to null. You should then wait for a brief period—ideally through a task delay—to allow the system to release the network resources before calling CreateCastingConnection on your CastingDevice again to obtain a fresh, clean instance.

    For maximum reliability, implement a watchdog timer that monitors the connection progress. If the state remains stuck at Connecting for more than ten seconds, you should programmatically force a reset of the device watcher. This ensures that the application forces the Windows shell to rediscover the Miracast receiver, which effectively flushes the faulty state synchronization and restores the correct status to your application's interface.

    Hope this answer brought you some useful information. If it did, please hit “accept answer”. Should you have any questions, feel free to leave a comment.

    VP

    War diese Antwort hilfreich?

    Eine Person fand diese Antwort hilfreich.
    0 Kommentare Keine Kommentare

  2. VPHAN 44,940 Zuverlässigkeitspunkte Unabhängiger Berater
    2026-04-18T06:54:31.68+00:00

    Hallo GOLF,

    Wie läuft dein Problem? Ist das Problem schon gelöst? Falls ja, erwägen Sie bitte, die Antwort zu akzeptieren , da sie auch anderen mit demselben Problem hilft, davon zu profitieren. Danke :)

    VP

    War diese Antwort hilfreich?

    0 Kommentare Keine Kommentare

Ihre Antwort

Antworten können von Fragestellenden als „Angenommen“ und von Moderierenden als „Empfohlen“ gekennzeichnet werden, wodurch Benutzende wissen, dass diese Antwort das Problem des Fragestellenden gelöst hat.