question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot get a ipc connection to run with aspnetcore 2.1 & angular 6

See original GitHub issue

Hello Gregor, Hello Robert, Hello all,

Thank you for this library!

I have a AspNetCore 2.1 Angular 6 App with ElectronApi 0.11. “electronize start” works fine and the app starts fine but I cannot get a ipc connection to run.

I have an Angular service with the following parts of code to establish a ipc connection. Its executing immediately after angular app start,

import { IpcRenderer } from 'electron'; ... if (process.versions.electron && (<any>window).require) this.ipc = (<any>window).require("electron").ipcRenderer; ... this.ipc.send("connect", "x");

This is my code on C# side

var browserWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions { Show = false }); browserWindow.OnReadyToShow += () => { Electron.IpcMain.On("connect", args => Connect()); browserWindow.Show(); };

if I make a sendSync on angular side, the app freezes. Do you have some idea what i did wrong.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
GregorBiswangercommented, May 16, 2019

Hey @ffetech, @jsantanders and other Angular Devs from our Community 😃

@ffetech I downloaded your sample code and immediately recognized the problem.

image

The ipcRenderer works asynchronously in the background. When a message arrives and your data is changed, no Angular Change Detection becomes active.

That’s because the Change Detection runs over Zone.js. This subscribes to all DOM events, XHR events, etc. - When these are triggered, only their call stack is processed. Then goes through the change detection. With otherwise asynchronous code, Zone.js does not recognize this.

The solution is to run your own asynchronous code in one zone. This automatically triggers a change detection. Here the updated code from your sample:

constructor(private ipc: IpcService, zone: NgZone) {
  this.ipc.on('asynchronous-reply', (event, args) => {
    zone.run(() => {
      this.message = `Asynchronous message reply: ${args}`;
    });
  });

  this.ipc.send("async-msg", 'ping');
}

p.s. I would disguise the zone call in the service. Looks like better… 😃

0reactions
PitySOFTcommented, Oct 30, 2019

I have the same issue with .Net Core 2.2 and 3.0 using a default MVC project but with Angular.

11 silly lifecycle electron.net.host@1.0.2 start: Returned: code: 1 signal: null 12 info lifecycle electron.net.host@1.0.2 start: Failed to exec start script 13 verbose stack Error: electron.net.host@1.0.2 start: tsc -p . "--port" "55259" 13 verbose stack Exit status 1

Any idea why this error and how to solve it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot GET / error in angular 6 .net core 2.1
To do this, just run the command npm start from VSCode npm console. ... This will be basically an error in your Angular...
Read more >
Create an ASP.NET Core app with Angular in Visual Studio
In this tutorial, you create an app using ASP.NET Core and Angular. ... You can use the method described in this article to...
Read more >
NET 6 Core Web App Returns web page not found
I am using Visual Studio 2022 17.4.0 Preview 2.1 and I got the same error when I attempt to run in .net 6...
Read more >
Getting Started With SignalR, .NET Core 2.1 And Angular
For testing purposes, I'm configuring the connection straight into the home component. import { Component, OnInit } from '@angular/core'; ...
Read more >
ASP.NET Core 2.1 Full Stack Web App - Part 01 - YouTube
NET Core 2.1, a standard MVC Web App using ASP .NET Core 2.1, and a Single-Page Application (SPA) using Angular. We'll use PostgreSQL...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found