© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago
just.a.hriday

(WinUI 3) Visual State Manager throwing System.Runtime.InteropServices.COMException

I use the
VisualStateMangaer.GoToState()
VisualStateMangaer.GoToState()
method twice, with the same parameters.
Strangely, it only works in one of the situations and throws an exception in the other. What am I missing here?
private void DialogLoaded (object sender, RoutedEventArgs e)
{
    VisualStateManager.GoToState(this, InternetConnected() ? "IsbnEnabled" : "IsbnDisabled", false);
    // This works perfectly fine.

    NetworkInformation.NetworkStatusChanged += delegate
    {
        bool connected = InternetConnected();

        VisualStateManager.GoToState(this, connected ? "IsbnEnabled" : "IsbnDisabled", false);
        // This one throws a System.Runtime.InteropServices.COMException with no message.
    };
}
private void DialogLoaded (object sender, RoutedEventArgs e)
{
    VisualStateManager.GoToState(this, InternetConnected() ? "IsbnEnabled" : "IsbnDisabled", false);
    // This works perfectly fine.

    NetworkInformation.NetworkStatusChanged += delegate
    {
        bool connected = InternetConnected();

        VisualStateManager.GoToState(this, connected ? "IsbnEnabled" : "IsbnDisabled", false);
        // This one throws a System.Runtime.InteropServices.COMException with no message.
    };
}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Unhandled Exception: System.Runtime.InteropServices.COMException:Unknown error (0x8007203b)
C#CC# / help
2y ago
Winui 3 titlebar problems
C#CC# / help
3y ago
ContentDialog Window using WinUI 3
C#CC# / help
14mo ago
❔ WinUI 3 Pivot Header Size
C#CC# / help
3y ago