ElectronNET/Electron.NET · critical · PlatformNotSupportedException

This Electron.NET application was built for

Error message

This Electron.NET application was built for '{buildInfoRid}'. It cannot run on this platform.

What it means

ElectronProcessActive.CheckRuntimeIdentifier compares the RID the app was built for (buildInfoRid) against the current OS/architecture and throws PlatformNotSupportedException when they cannot run together (e.g. a win7-x64 build launched on Linux). This guards against launching an Electron binary that cannot execute on the host.

Solutions

  1. Rebuild/re-publish for the target platform: dotnet publish -r linux-x64 (or the matching RID)
  2. Ensure the deploy environment OS/arch matches the build RID
  3. Check buildInfo (electronbuildinfo.json / build metadata) points at the correct RID
  4. For self-contained deployments, publish per-platform artifacts and deploy the matching one

Example fix

// before
dotnet publish -r win-x64 --self-contained false   # then run on Linux
// after
dotnet publish -r linux-x64 --self-contained false  # run on Linux
Defensive patterns

Strategy: validation

Validate before calling

var rid = GetBuildInfoRid(); // from electronbuildinfo.json
var current = RuntimeInformation.ProcessArchitecture;
bool compatible = (OperatingSystem.IsWindows() && rid.StartsWith("win") ||
                   OperatingSystem.IsLinux() && rid.StartsWith("linux") ||
                   OperatingSystem.IsMacOS() && rid.StartsWith("osx"))
                  && rid.EndsWith(current.ToString().ToLower());
if (!compatible) throw new PlatformNotSupportedException($"Build RID {rid} incompatible with current platform");

Try / catch

try
{
    await ElectronBootstrap.LaunchAsync();
}
catch (PlatformNotSupportedException ex)
{
    logger.LogCritical(ex, "Runtime identifier mismatch — rebuild for {Platform}", Environment.OSVersion.Platform);
    Environment.Exit(1);
}

Prevention

When it happens

Trigger: Publishing/porting the app with a runtime identifier (e.g. win-x64) and running it on a different OS or architecture, such as moving a Windows build to Linux or an x64 build onto ARM.

Common situations: Copying build output between machines/containers of a different OS; CI publishing with --runtime for one platform but deploying to another; missing RID in buildInfo causing a mismatch; Docker image base OS mismatch.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.


AI-assisted analysis of ElectronNET/Electron.NET@87cc6f98b6 (2026-09-14). Data as JSON: /api/errors/2e88b05d34dcc55a. Report an issue: GitHub.

Appendix: source

Thrown at src/ElectronNET.API/Runtime/Services/ElectronProcess/ElectronProcessActive.cs:153

                    {
                        mismatch = true;
                    }

                    break;

                case "freebsd":

                    if (!RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD))
                    {
                        mismatch = true;
                    }

                    break;
            }

            if (mismatch)
            {
                throw new PlatformNotSupportedException($"This Electron.NET application was built for '{buildInfoRid}'. It cannot run on this platform.");
            }
        }

        protected override Task StopCore()
        {
            this.process.Cancel();
            return Task.CompletedTask;
        }

        private async Task StartInternal(string startCmd, string args, string directory)
        {
            var tcs = new TaskCompletionSource();
            using var cts = new CancellationTokenSource(2 * 60_000); // cancel after 2 minutes
            using var _ = cts.Token.Register(() =>
            {
                // Time is over - let's kill the process and move on
                this.process.Cancel();
                // We don't want to raise exceptions here - just pass the barrier

View on GitHub (pinned to 87cc6f98b6)