mgth/LittleBigMouse · error · InvalidOperationException

Associate a Samsung Tizen display first.

Error message

Associate a Samsung Tizen display first.

What it means

SamsungTizenService.RequiredConfiguration fetches the stored SamsungTizenConfiguration for a monitorId and validates that it exists and has a non-blank IpAddress. If not, it throws InvalidOperationException: no Samsung Tizen display has been associated with this monitor, so no remote-control operation can proceed.

Solutions

  1. Run the Samsung Tizen association/pairing flow to create a configuration with an IP address for this monitorId
  2. Verify the display is actually a Samsung Tizen model and is mapped to the correct monitorId
  3. Check that the configuration store persists and returns the saved entry (no reset/corruption)

Example fix

// before
await service.PowerOffAsync(monitorId); // throws if unassociated
// after
if (!service.IsAssociated(monitorId))
    throw new InvalidOperationException("Associate a Samsung Tizen display in settings first.");
await service.PowerOffAsync(monitorId);
Defensive patterns

Strategy: validation

Validate before calling

var config = store.Get(monitorId);
if (config is null || string.IsNullOrWhiteSpace(config.IpAddress))
    throw new InvalidOperationException("Associate a Samsung Tizen display first.");

Type guard

static bool IsAssociated(SamsungTizenConfiguration? c) =>
    c is not null && !string.IsNullOrWhiteSpace(c.IpAddress);

Try / catch

try
{
    await service.PowerOnAsync(monitorId, ct);
}
catch (InvalidOperationException)
{
    // navigate user to the Samsung Tizen association flow
}

Prevention

When it happens

Trigger: Calling any service operation that resolves a configuration (PowerOnAsync, power/volume commands, ClientFor) for a monitorId whose stored configuration is null or whose IpAddress is null/whitespace.

Common situations: The user never ran the Samsung Tizen association/pairing flow for that monitor; the monitor is a non-Tizen display wrongly assigned to the Tizen plugin; configuration storage was reset or migrated and the entry was lost.

Understand the failure class

Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.

Related errors


AI-assisted analysis of mgth/LittleBigMouse@7a42f01d47 (2026-09-16). Data as JSON: /api/errors/925bbfc38f576734. Report an issue: GitHub.

Appendix: source

Thrown at LittleBigMouse.Plugins/LittleBigMouse.Plugin.Vcp.Avalonia/SamsungTizen/SamsungTizenService.cs:142

        PacketCount = 3,
        Port = 9,
        DelayBetweenPackets = TimeSpan.FromMilliseconds(100),
    };

    public Task PowerOnAsync(string monitorId, CancellationToken cancellationToken = default)
    {
        var configuration = RequiredConfiguration(monitorId);
        if (string.IsNullOrWhiteSpace(configuration.MacAddress))
            throw new InvalidOperationException("Enter the monitor Wi-Fi MAC address before using Wake-on-LAN.");
        return WakeOnLan.SendAsync(
            configuration.MacAddress, WakeOnLanBurst, cancellationToken: cancellationToken);
    }

    SamsungTizenConfiguration RequiredConfiguration(string monitorId)
    {
        var configuration = _store.Get(monitorId);
        if (configuration is null || string.IsNullOrWhiteSpace(configuration.IpAddress))
            throw new InvalidOperationException("Associate a Samsung Tizen display first.");
        return configuration;
    }

    SamsungTizenClient ClientFor(string monitorId, SamsungTizenConfiguration configuration)
    {
        lock (_lock)
        {
            if (_clients.TryGetValue(monitorId, out var client)) return client;
            client = new SamsungTizenClient(configuration.IpAddress, configuration.Token);
            _clients[monitorId] = client;
            return client;
        }
    }

    public async ValueTask DisposeAsync()
    {
        SamsungTizenClient[] clients;
        lock (_lock)

View on GitHub (pinned to 7a42f01d47)