ElectronNET / Electron.NET

:electron: Build cross platform desktop apps with ASP.NET Core (Razor Pages, MVC, Blazor).

Home Page:https://gitter.im/ElectronNET/community

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue when upgrade from 5.0 to 6.0

vinnaykulkarni opened this issue · comments

When updated from core 5 to 6 getting following error, however when compiled with 5 with Electron version of 13.5.1 works well

C:\Program Files\dotnet\sdk\6.0.408\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(464,5): error : Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. [Project.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.408\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(464,5): error : Repeat 2 times: [Project.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.408\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(464,5): error : -------------------------------- [Project.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.408\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(464,5): error : at Internal.JitInterface.CorInfoImpl.JitCompileMethod(IntPtr ByRef, IntPtr, IntPtr, IntPtr, Internal.JitInterface.CORINFO_METHOD_INFO ByRef, UInt32, IntPtr ByRef, UInt32 ByRef) [Project.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.408\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(464,5): error : -------------------------------- [Project.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.408\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(464,5): error : at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(ILCompiler.DependencyAnalysis.IMethodNode, Internal.IL.MethodIL) [Project.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.408\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(464,5): error : at Internal.JitInterface.CorInfoImpl.CompileMethod(ILCompiler.DependencyAnalysis.ReadyToRun.MethodWithGCInfo, ILCompiler.Logger) [Project.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.408\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(464,5): error : at ILCompiler.ReadyToRunCodegenCompilation.b__36_0(ILCompiler.DependencyAnalysisFramework.DependencyNodeCore1<ILCompiler.DependencyAnalysis.NodeFactory>) [Project.Web.csproj] C:\Program Files\dotnet\sdk\6.0.408\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(464,5): error : at System.Threading.Tasks.Parallel+<>c__DisplayClass33_02[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].b__0(Int32) [Project.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.408\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(464,5): error : at System.Threading.Tasks.Parallel+<>c__DisplayClass19_0`1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].b__1(System.Threading.Tasks.RangeWorker ByRef, Int32, Boolean ByRef) [Project.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.408\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(464,5): error : at System.Threading.Tasks.TaskReplicator+Replica.Execute() [Project.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.408\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(464,5): error : at System.Threading.Tasks.TaskReplicator+Replica+<>c.<.ctor>b__4_0(System.Object) [Project.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.408\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(464,5): error : at System.Threading.Tasks.Task.InnerInvoke() [Project.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.408\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(464,5): error : at System.Threading.Tasks.Task+<>c.<.cctor>b__272_0(System.Object) [Project.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.408\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(464,5): error : at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(System.Threading.Thread, System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) [Project.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.408\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(464,5): error : at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread) [Project.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.408\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(464,5): error : at System.Threading.Tasks.Task.ExecuteEntryUnsafe(System.Threading.Thread) [Project.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.408\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(464,5): error : at System.Threading.ThreadPoolWorkQueue.Dispatch() [Project.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.408\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(464,5): error : at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart() [Project.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.408\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(464,5): error : at System.Threading.Thread.StartCallback() [Project.Web.csproj]
C:\Program Files\dotnet\sdk\6.0.408\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(352,5): error NETSDK1096: Optimizing assemblies for performance failed. You can either exclude the failing assemblies from being optimized, or set the PublishReadyToRun property to false. [Project.Web.csproj]

When PublishReadytoRun=true is removed then publish works however only splash screens is seen and application is not strated, but when accessed the via browser the application is accessible, seems browser window is not initiated and application remains in loop at splash screen

commented

Hi @vinaykulkarni89
Can you provide information on the Node JS Version?
And did you install the latest Nuget package for Electron.NET 23.6.1?

For .NET to run as an electron application, the Node JS version should be at least 16.17.1. (Use 18.16.0 if possible)
And also, try upgrading the Electron.NET version from the developer powershell dotnet tool update --global ElectronNET.CLI
Delete the host folder and repeat the process which you did for running the .NET 5 electron application for the first time.
This will make you run the electron application in .NET 6.0🙂

Hi @arun04cbe thanks for the comment
The Electron CLI is updated node is on 18 LTS, tried clearing bin and obj folders too
Electron package is also to latest stable
Still same issue

Even tried setting up new environment with only required SDk and packages but still no luck

Have you checked event viewer?

I had the same error that after update (13.5.1 => 23.6.1) production version of the app crashed on splashscreen.

Found from event logs:

Application: AppXXX.exe
CoreCLR Version: 6.0.1623.17311
.NET Version: 6.0.16
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException: Could not load file or assembly 'System.Text.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
File name: 'System.Text.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
at SocketIOClient.JsonSerializer.SystemTextJsonSerializer..ctor()
at SocketIOClient.SocketIO.Initialize()
at SocketIOClient.SocketIO..ctor(Uri uri, SocketIOOptions options)
at SocketIOClient.SocketIO..ctor(Uri uri)
at SocketIOClient.SocketIO..ctor(String uri)
at ElectronNET.API.SocketIoFacade..ctor(String uri)
at ElectronNET.API.BridgeConnector.get_Socket()
at ElectronNET.API.WindowManager.CreateWindowAsync(BrowserWindowOptions options, String loadUrl)
at BC.BEM.FileTransfer.Startup.CreateElectronWindow(Boolean isProduction) in D:\a\1\s\bemfiletransfer\Startup.cs:line 99
at System.Threading.Tasks.Task.<>c.b__128_1(Object state)
at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
at System.Threading.Thread.StartCallback()

I just updated my project target framework to .net 7 and now its working.

Sorry to hear that you're experiencing this issue. Upgrading from .NET Core 5 to .NET 6 seems to have surfaced a memory management issue as per the error logs you've shared.

Here are some potential solutions to your problem:

  1. Check Compatibility of NuGet Packages: Please ensure that all the NuGet packages that you're using in your project are compatible with .NET 6. It's possible that one or more packages haven't been updated for .NET 6 yet and thus are causing issues.

  2. Disable PublishReadyToRun Option: As suggested in the error message, you could try disabling the PublishReadyToRun option. You can do this by adding the following line to your .csproj file:

<PropertyGroup>
  <PublishReadyToRun>false</PublishReadyToRun>
</PropertyGroup>
  1. Disable CrossGen Compilation: Another potential workaround could be disabling CrossGen compilation. This may make your program run slower, but it could bypass the memory access issue. You can do this by adding the following line to your .csproj file:
<PropertyGroup>
  <CrossGenDuringPublish>false</CrossGenDuringPublish>
</PropertyGroup>

Please note that these changes may result in reduced performance. Therefore, it's important to identify and fix the root cause of the problem rather than just using workarounds.

  1. Rebuild the Project and Clean the Solution: Sometimes, build issues can be resolved by simply rebuilding the project and cleaning the solution. Try this before moving to more drastic measures.

  2. Search for Specific Solutions: As your error is quite specific and points to a particular point in your build targets, you might try searching for solutions for this specific error. You could, for example, look for similar problems in forums or on Stack Overflow.

If none of these steps resolve the issue, it might be helpful to provide additional information such as the exact code causing the issue or details about the environment you're working in. I hope this helps! Please let me know how it goes.