Application does start with net5.0 with low level or unmanaged c# libraries
Hi there!
- Version: 13.5.1
- Target: net5.0
Steps to Reproduce:
I would like to run a simple app where I want to instantiate a Basler camera (emulation for now). To do that, I just have to import the library and do a simple Camera camera = new Camera();
My netcore app has been created with the microsoft new project with react and redux, then I add electron.net api and I started the electronize init / start command
Here is the service I registered with the classic microsoft DI :
using System;
using Basler.Pylon;
using ElectronNET.API;
using Microsoft.Extensions.Logging;
public class CameraService : ICameraService
{
private readonly ILogger<CameraService> _logger;
public CameraService(ILogger<CameraService> logger)
{
_logger = logger;
Camera c = new Camera();
_logger.LogInformation(c.ToString());
Electron.IpcMain.On("cam", async args =>
{
try
{
Camera c = new Camera();
_logger.LogInformation(c.ToString());
}
catch (Exception e)
{
_logger.LogError(e.Message);
}
});
}
}
Here are the different behaviors I have with different situations:
Situation 1 - simple console app with net 5.0 : -> working because I can access the object and Emulation (0815-0000) and open the camera
info: akatech.ui.electron.Services.CameraService[0]
Emulation (0815-0000)
situation 2 - run this application with visual studio debug/run : -> working because I can access the object and Emulation (0815-0000) and open the camera
info: akatech.ui.electron.Services.CameraService[0]
Emulation (0815-0000)
info: Microsoft.Hosting.Lifetime[0]
Now listening on: https://localhost:5001
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\Dev\Projects\Akatech\akatech.ui.electron\akatech.ui.electron
Situation 3 - When I run the application with electronize start command
it stops here and nothing happen, no errors, no messages, waiting indefinitely
Electron Socket IO Port: 8009
Electron Socket started on port 8009 at 127.0.0.1
ASP.NET Core Port: 8010
stdout: Use Electron Port: 8009
Situation 4 - When I remove the first Camera camera = new Camera() before the Electron.IpcMain.On in order try to create the camera after the application is completely started
public class CameraService : ICameraService
{
private readonly ILogger<CameraService> _logger;
public CameraService(ILogger<CameraService> logger)
{
_logger = logger;
//Camera c = new Camera();
//_logger.LogInformation(c.ToString());
Electron.IpcMain.On("cam", async args =>
{
try
{
Camera c = new Camera();
_logger.LogInformation(c.ToString());
}
catch (Exception e)
{
_logger.LogError(e.Message);
}
});
}
}
When the event is triggered by the frontend with
electron.ipcRenderer.send('cam', "info")
I got just an error Got disconnected! Reason: transport close
Electron Socket IO Port: 8010
Electron Socket started on port 8010 at 127.0.0.1
ASP.NET Core Port: 8011
stdout: Use Electron Port: 8010
stdout: ASP.NET Core host has fully started.
stdout: info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://localhost:8011
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\Dev\Projects\Akatech\akatech.ui.electron\obj\Host\bin
ASP.NET Core Application connected... global.electronsocket KF4Hi45LKbloPX_VAAAA 2021-09-18T10:32:28.540Z
stdout: BridgeConnector connected!
(node:21916) electron: The default of contextIsolation is deprecated and will be changing from false to true in a future release of Electron. See https://github.com/electron/electron/issues/23506 for more information
stdout: warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]
Failed to determine the https port for redirect.
Got disconnect! Reason: transport close
I tried to add a breakpoint before the new camera in the IPC (situation 4) with the attatch process feature. I got this exception but I don't now if it is correlated System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

situation 5 : I did also clone the https://github.com/ElectronNET/electron.net-musicplayer-sample sample which is netcore3.1 and Electron.net api 5.30.1 and everything is working (IPC event create camera and create camera at the class instanciation) I also noticed that this sample with the same api 5.30.1 with netcore5 instead of netcore3.1 also does not work (same behavior as the situation 3 and 4)
We really do want to use netcore5 as well as the latest versions of your library that is very promising!
I really hope someone could help us ! 👍