From 5b597cc12c4ae8450f4c37cb58742ef7050f3e9d Mon Sep 17 00:00:00 2001 From: softworkz Date: Sun, 9 Nov 2025 02:40:15 +0100 Subject: [PATCH] StartupManager: Add support for running under testhost --- src/ElectronNET.API/Runtime/StartupManager.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ElectronNET.API/Runtime/StartupManager.cs b/src/ElectronNET.API/Runtime/StartupManager.cs index a405a6e..fd17d26 100644 --- a/src/ElectronNET.API/Runtime/StartupManager.cs +++ b/src/ElectronNET.API/Runtime/StartupManager.cs @@ -128,9 +128,21 @@ { var buildInfo = new BuildInfo(); - var attributes = Assembly.GetEntryAssembly()?.GetCustomAttributes().ToList(); + var electronAssembly = Assembly.GetEntryAssembly(); - if (attributes?.Count > 0) + if (electronAssembly == null) + { + return buildInfo; + } + + if (electronAssembly.GetName().Name == "testhost") + { + electronAssembly = AppDomain.CurrentDomain.GetData("ElectronTestAssembly") as Assembly ?? electronAssembly; + } + + var attributes = electronAssembly.GetCustomAttributes().ToList(); + + if (attributes.Count > 0) { buildInfo.ElectronExecutable = attributes.FirstOrDefault(e => e.Key == nameof(buildInfo.ElectronExecutable))?.Value; buildInfo.ElectronVersion = attributes.FirstOrDefault(e => e.Key == nameof(buildInfo.ElectronVersion))?.Value;