#Include another app in ElectronJS

6 messages · Page 1 of 1 (latest)

thorn star
#

Heya guys,
I am currently creating a Electronjs App and there is a Button which Opena another App from the Folder. Which is a C# Application.

The tree looks like:

/softwares/
|
|
CsharpApp.exe
Csharpapp.dll
another.dll
another2.dll

And i use NSIS to Build my Application. If i "npm start" my C# Application will be open, when i click on "Open C# App" button in ElectronJS (html).
But when I build it (npm run builds), then it gives me a error when clicked on Button.

Error: spawn (electronapp/softwares/CsharpApp.exe) ENOENT

I sadly have no clue why it does not include the C# app in builder.

I would appreciate it, if someone finds a way to help. Thank you :)

thorn star
#

package.json:

  "build": {
    "productName": "Application Client",
    "appId": "djmahirnationtv.app.id",
    "win": {
      "target": [
        "nsis"
      ],
      "icon": "./assets/icons/icon.ico"
    },
    "nsis": {
      "deleteAppDataOnUninstall": true,
      "oneClick": true,
      "installerIcon": "./assets/icons/icon.ico",
      "uninstallerIcon": "./assets/icons/icon.ico",
      "uninstallDisplayName": "Application Client Uninstaller ${version}",
      "license": "LICENSE.md",
      "allowToChangeInstallationDirectory": false
    }
  }

main.js (csharp include:

  function openCSharpApp() {
    if (csharpAppProcess && !csharpAppProcess.killed) {
      csharpAppProcess.kill();
    }

    // Spawn a new process for the C# application
    csharpAppProcess = spawn('./assets/softwares/csharpsoftware.exe', []);

    csharpAppProcess.on('close', (code) => {
      console.log(`restarted application!`);
    });
  }

index.html

            <a href="#" id="openCSharpAppButton">
              <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
                class="bi bi-person-badge" viewBox="0 0 16 16">
                <path d="M6.5 2a.5.5 0 0 0 0 1h3a.5.5 0 0 0 0-1zM11 8a3 3 0 1 1-6 0 3 3 0 0 1 6 0" />
                <path
                  d="M4.5 0A2.5 2.5 0 0 0 2 2.5V14a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V2.5A2.5 2.5 0 0 0 11.5 0zM3 2.5A1.5 1.5 0 0 1 4.5 1h7A1.5 1.5 0 0 1 13 2.5v10.795a4.2 4.2 0 0 0-.776-.492C11.392 12.387 10.063 12 8 12s-3.392.387-4.224.803a4.2 4.2 0 0 0-.776.492z" />
              </svg>
              Open CSharp Software
            </a>
#

The folder (softwares)

#

ipcRenderer.js:

const { ipcRenderer } = require("electron");

document.getElementById('openCSharpAppButton').addEventListener('click', () => {
    ipcRenderer.send('openCSharpApp');
});

The Issue is, if I debug then It will work and open. but if I build it with NSIS, then it will return me a error

#

ERROR:

#

the blurred is the App name example "csharp.exe"