mgth/LittleBigMouse · error · ArgumentException
Enter a valid projector IPv4 address.
Error message
Enter a valid projector IPv4 address.
What it means
NetworkIdentity.ControllerMacFor determines which local network interface (and thus which controller MAC) would be used to reach the projector. Before doing so it parses remoteAddress as an IPv4 address with Ipv4Address.TryParse; if parsing fails it throws this ArgumentException naming the remoteAddress parameter. It validates input format up front rather than failing later in socket setup.
Solutions
- Pass a valid dotted-quad IPv4 string (e.g. "192.168.1.50") as remoteAddress.
- Resolve any hostname to an IPv4 address before calling, using Dns.GetHostAddresses and picking the IPv4 entry.
- Validate the IP field in the UI/config layer with IPAddress.TryParse before storing or passing it.
- Trim and normalize user-entered addresses (remove port, whitespace) before calling the API.
Example fix
// before
var mac = NetworkIdentity.ControllerMacFor("projector.local");
// after
if (!IPAddress.TryParse(host, out var addr) || addr.AddressFamily != AddressFamily.InterNetwork)
throw new ArgumentException("Provide an IPv4 address for the projector.");
var mac = NetworkIdentity.ControllerMacFor(addr.ToString()); Defensive patterns
Strategy: validation
Validate before calling
if (!IPAddress.TryParse(remoteAddress, out var ip) || ip.AddressFamily != AddressFamily.InterNetwork)
throw new ArgumentException("Projector address must be a valid IPv4 address.", nameof(remoteAddress)); Type guard
static bool IsIpv4(string? s) =>
IPAddress.TryParse(s, out var ip) && ip.AddressFamily == AddressFamily.InterNetwork; Try / catch
try
{
var mac = NetworkIdentity.ControllerMacFor(remoteAddress);
}
catch (ArgumentException ex) when (ex.ParamName == "remoteAddress")
{
// prompt user for a valid dotted-quad IPv4 address
} Prevention
- Validate the IP field with IPAddress.TryParse in the UI before saving.
- Resolve hostnames to IPv4 with DNS before calling network APIs.
- Trim user input and reject values containing ':' or whitespace.
When it happens
Trigger: Calling ControllerMacFor with a remoteAddress string that is not a parseable IPv4 address: hostname instead of IP, IPv6 string, empty/null string, trailing whitespace or typo like '192.168.1.256'.
Common situations: User typed a hostname (e.g. 'projector.local') into the IP field; config value copied with whitespace or port appended ('192.168.1.50:36669'); localization or UI let a malformed address through; IPv6-only network where the projector address is an IPv6 literal.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Enter a valid projector IPv4 address.
- Enter a valid IPv4 address.
- Invalid VIDAA remote key.
- Enter a VIDAA picture-setting menu ID between 1 and 999.
- Enter a VIDAA picture-setting value between -1000 and 1000.
AI-assisted analysis of mgth/LittleBigMouse@7a42f01d47 (2026-09-16).
Data as JSON: /api/errors/350411830879b5a9.
Report an issue: GitHub.
Appendix: source
Thrown at LittleBigMouse.Plugins/LittleBigMouse.Plugin.Vcp.Avalonia/HisenseVidaa/NetworkIdentity.cs:14
#nullable enable
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using LittleBigMouse.Plugin.Vcp.Networking;
namespace LittleBigMouse.Plugin.Vcp.Avalonia.HisenseVidaa;
static class NetworkIdentity
{
public static string ControllerMacFor(string remoteAddress)
{
if (!Ipv4Address.TryParse(remoteAddress, out var remote))
throw new ArgumentException("Enter a valid projector IPv4 address.", nameof(remoteAddress));
using var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
socket.Connect(new IPEndPoint(remote, HisenseVidaaProtocol.MqttPort));
var local = ((IPEndPoint)socket.LocalEndPoint!).Address;
foreach (var network in NetworkInterface.GetAllNetworkInterfaces())
foreach (var address in network.GetIPProperties().UnicastAddresses)
if (address.Address.Equals(local))
return HisenseVidaaProtocol.NormalizeMac(network.GetPhysicalAddress().ToString());
throw new InvalidOperationException($"Could not find the network interface used to reach {remoteAddress}.");
}
}
View on GitHub (pinned to 7a42f01d47)