Skip to content

niteshsinghal85/ElectronNetSampleApp

Repository files navigation

Electron.NET Sample App

A sample application demonstrating how to build desktop applications using Electron.NET, a framework that combines ASP.NET Core with Electron to create cross-platform desktop applications.

Overview

This project showcases an Electron.NET application built with:

  • ASP.NET Core (.NET 8.0) - Backend and web framework
  • Electron.NET - Desktop application integration
  • Razor Pages - Frontend UI
  • Custom Electron Main Process - Advanced Electron configuration

Project Structure

ElectronNetSampleApp/
├── Pages/                  # Razor Pages for UI
├── Properties/             # Build and launch configuration
├── wwwroot/                # Static files (CSS, JS, libraries)
├── electron/               # Electron-specific files
│   └── custom_main.js      # Custom Electron main process
├── appsettings.json        # Application settings
├── Program.cs              # Application startup configuration
└── ElectronNetSampleApp.csproj

Prerequisites

  • .NET 8.0 SDK or later
  • Node.js (required for Electron)
  • npm or yarn (for managing Electron dependencies)
  • Windows (configured for win-x64 runtime)

Getting Started

1. Clone the Repository

git clone https://github.com/yourusername/explore_electron_net.git
cd explore_electron_net

2. Restore Dependencies

dotnet restore

3. Build the Application

dotnet build

4. Run the Application

dotnet run

The desktop application window should launch automatically.

Development

Building for Distribution

To build a distributable Electron package:

dotnet publish -c Release

The Electron builder configuration is located in Properties/electron-builder.json.

Custom Electron Main Process

This project uses a custom Electron main process (electron/custom_main.js) for advanced configuration. See the CUSTOM_MAIN_GUIDE.md file for implementation details.

Project Configuration

Key settings are defined in:

  • appsettings.json - General application settings
  • appsettings.Development.json - Development-specific settings
  • Properties/launchSettings.json - Launch profiles

Dependencies

NuGet Packages

  • ElectronNET.Core - Core Electron.NET runtime
  • ElectronNET.Core.API - Electron API bindings
  • ElectronNET.Core.AspNet - ASP.NET Core integration

Node.js Dependencies

Managed through Electron's integrated npm environment.

Architecture

Frontend

  • Razor Pages for server-rendered UI
  • Bootstrap for responsive design
  • jQuery for client-side interactions
  • jQuery Validation for form validation

Backend

  • ASP.NET Core middleware pipeline
  • Razor Pages with code-behind support
  • Built-in dependency injection via Electron.NET

Desktop Integration

  • Custom Electron main process for advanced window management
  • Auto-hiding menu bar for cleaner UI
  • Window ready detection for optimal load handling

Features

  • Cross-platform desktop application (configured for Windows)
  • Server-rendered UI with Razor Pages
  • Built-in web server powered by ASP.NET Core
  • Seamless integration between .NET and Electron
  • Customizable Electron main process

Troubleshooting

Node.js not found

Ensure Node.js is installed and available in your PATH.

Build errors

Clear the build artifacts:

dotnet clean
dotnet restore
dotnet build

Electron window won't launch

Check that the ASP.NET Core server is running and accessible. Verify appsettings.json for correct port configuration.

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Resources

Contact

For questions or support, please open an issue in the GitHub repository.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published