Open CharlieNewmedia opened 1 month ago
Does it work on your PC when you copy it to a separate folder similar to F:\electron-edge-js-quick-start-forge-win32-x64
that you have on another PC? I am assuming that both PCs are Windows. Did you use publish
or make
?
I did notice that there was an issue with original example with missing author
in package.json
. Updated to remove errors on make
I had already fixed the make(Author) error. However I have the same error with both "npm run package" and "npm run make". I run the commands from Windows 11 (where I have Netcore SDK and Node installed), then I copy the "electron-edge-js-quick-start-forge-win32-x64" folder into the USB stick and run it on a Windows 10 computer (where there is no sdk and node, but I installed dotnetcore8runtime ), the error is always the same! Where am I wrong? On windows 11 everything works correctly Thanks
To be honest I don't actually know what is wrong and do not have a way of replicating the problem on my end. Redistributable should definitely be created with make
and not publish
but beyond that cannot thing of anything else.
I will try a few things to see if I can spot something obvious.
Tried the following:
make
with additional parameter --arch=arm64
to create arm64 distribution. But there is a big caveat to this - my Windows 11 VM has all the build tools, SDKs etc installed. I can only assume that something is missing there but do not know what it is.
One possibility is that you might need Visual C++ Redistributable either 2019 or 2022 but that's a shot in the dark right now.
I will have a closer look at this and will let you know if I find anything.
EDIT: Here is something that you should try, publish .NET code as standalone. From project root run dotnet publish src/QuickStart.sln --self-contained
.
Then use electron-edge-js-quick-start-forge\src\QuickStart.Core\bin\Release\net8.0\publish
folder for binaries. Make sure to use publish
folder inside net8.0
not net8.0
itself.
I am working on getting a fresh Windows 11 VM for testing but this will take a few hours so do not expect update soon.
Hi, I tried to publish the .net code with dotnet publish src/QuickStart.sln --self-contained
and withdotnet publish src/QuickStart.sln --self-contained -r win-x64 -c Release
but already when I do npm start it gives me this error:
npm start
electron-edge-js-quick-start-forge@1.0.0 start electron-forge start
✔ Checking your system ✔ Locating application ✔ Loading configuration ✔ Preparing native dependencies [1s] ✔ Running generateAssets hook
15:54:50.291 > framework: Core
15:54:50.307 > NODE_PATH: undefined
15:54:50.309 > EDGE_USE_CORECLR: 1
15:54:50.310 > [
'E:\Progetti\electron-edge-js-quick-start-forge\node_modules',
'E:\Progetti\node_modules',
'E:\node_modules'
]
15:54:50.312 > process.env.EDGE_APP_ROOT: E:\Progetti\electron-edge-js-quick-start-forge\src\QuickStart.Core\bin\Release\net8.0\win-x64\publish\
15:54:50.313 > process.env.DOTNET_ROOT: E:\Progetti\electron-edge-js-quick-start-forge\src\QuickStart.Core\bin\Release\net8.0\win-x64\publish\
Load edge native library from: E:\Progetti\electron-edge-js-quick-start-forge\node_modules\electron-edge-js\lib\native\win32\x64\31.0.0\edge_coreclr
15:54:50.426 > baseNetAppPath: E:\Progetti\electron-edge-js-quick-start-forge\src\QuickStart.Core\bin\Release\net8.0\win-x64\publish\
15:54:50.427 > E:\Progetti\electron-edge-js-quick-start-forge\src\QuickStart.Core\bin\Release\net8.0\win-x64\publish\QuickStart.Core.dll
15:54:50.429 > TypeError: edge.initializeClrFunc is not a function
at exports.func (E:\Progetti\electron-edge-js-quick-start-forge\node_modules\electron-edge-js\lib\edge.js:177:17)
at Object.
I also tried setting process.env.DOTNET_ROOT on both the publish folder and the .netCore runtime.
strange, it seems that in the standalone version it can't load the dll correctly.
I tried the same dotnet publish src/QuickStart.sln --self-contained
and then changing the line in app.js
to let baseNetAppPath = path.join(__dirname, '/src/QuickStart.Core/bin/Release/net8.0/publish');
and it works fine for me.
On Windows 11 now getting the same error as you did, will try to figure it out.
So far narrowed down the problem to .NET SDK - if I install it on VM everything runs smoothly, without it TypeError: edge.initializeClrFunc is not a function
.
There must be something wrong with publishing, when using dotnet publish
the client system should not require even a runtime as it is a standalone app.
Exact! I encountered the same situation. Most likely you also need to make edge.dll standalone otherwise look for references on the SDK... but I could be wrong. I also saw that it has many references to .nuget/packages.
thanks
Each dll does not need to be published separately when you run dotnet publish src/QuickStart.sln --self-contained -r win-x64 -c Release
all dependencies including .NET Runtime will be pulled in and should be marked as published and standalone.
This could be a bug in edge-js
dependency resolution when running in standalone mode, will take some time to investigate properly.
EDIT: It appears that the issue is with node_modules\electron-edge-js\lib\bootstrap\bin\Release\bootstrap.dll
will try to resolve it.
Unfortunately the issue is not with node_modules\electron-edge-js\lib\bootstrap\bin\Release\bootstrap.dll
but with underlying functionality of dependency resolver in standalone apps. This will take a while to fix no ETA at the moment.
Should be complete in a couple of days however will have some drawbacks. Publishing it as a completely standalone project without any .NET CLR installed will require additional steps.
Hey, got the same problem. Application runs ok when i have the dotnet SDK insatalled but when im trying to do that on another computer without installed sdk it gives me that error. So is that a problem with electron-edge-js or with dotnet project packaging?
Still working on it but its getting closer. The problem is with edge-js
that carries over to electron-edge-js
as underlying code is the same.
Fix released for edge-js
will be merged to electron-edge-js
soon. It removes requirement for any .NET CLR installation Runtime or SDK but there will be some caveats to C# code to adjust for unresolved issues.
New electron-edge-js
released .NET published applications can run without any .NET Runtime/SDK present.
However there are caveats to C# implementation when calling dll methods.
Due to cross-domain collision between .NET CLR dlls loaded by edge-js
internally in standalone mode and .NET CRL dlls loaded when referencing a dll dynamic objects cannot be accessed directly.
This code from quick-start will no longer work
public async Task<object> UseDynamicInput(dynamic input)
{
return $".NET {input.framework} welcomes {input.node}";
}
Instead input
needs to be converted to a different object and then accessed for example
public async Task<object> UseDynamicInput(dynamic input)
{
var dict = (IDictionary<string, object>)input;
return $".NET {dict["framework"]} welcomes {dict["node"]}";
}
Issue: System.Dynamic.ExpandoObject passed as dynamic
from Node.js is loaded from different domain than System.Dynamic.ExpandoObject in referenced dll.
quick-start-forge updated to reference new electron-edge-js
package.
Hey, really appreciate what you are doing! Unfortunatelly i still can't open builded example on another windows where .NEW runtime/SDK is not installed.
I was going step by step on a electron-forge example on my win11, and then transferred builded version to my clean win10 system. When i was clicking on .exe file nothing happens, but when i have installed the latest .NET from dotnet.microsoft.com/en-us/download it worked and i was able to run a build.
I was wondering is there any way how we can pack .net sdk/runtime into a build?
Again thank you for your work and support!
Let me give it another try, it worked on my PC.
EDIT: did you publish your .NET library using dotnet publish src/QuickStart.sln --self-contained -r win-x64 -c Release
and then copying those files to dotnet folder?
Files will publish to src\QuickStart.Core\bin\Release\net8.0\win-x64\publish
Stopped working on my PC as well, will check what is happening there, but you definitely need to publish your .NET library first. Only inline C# code breaks for unknown reason calls to dll work.
For now I would suggest commenting out inline C# code and only using dll calls.
Hey, tried that and unfortunately got the same result. Without any .net sdks build is not working
Did you follow dotnet publish
instructions? I am not able to replicate any problems after correctly publishing .NET library.
@CharlieNewmedia is the issue resolved for you when using this project without inline c# code?
@agracio Hey, i'm sorry for the late response. Got really messed up week. I tried with dotnet publish and moved files from src\QuickStart.Core\bin\Release\net8.0\win-x64\publish to \electron-edge-js-quick-start-forge\out\electron-edge-js-quick-start-forge-win32-x64\resources\net8.0
but it stopped working even on my main system, when i'm clicking on the .exe file nothing happens
Try this:
electron-edge-js
Project updated with latest dependencies.
Hey, that's what i got after those steps on my main system
18:26:51.609 > framework: Core
18:26:51.623 > NODE_PATH: undefined
18:26:51.624 > EDGE_USE_CORECLR: 1
18:26:51.625 > [
'C:\Users\oleksii.kurakin\WebstormProjects\electron-edge-js-quick-start-forge\out\electron-edge-js-quick-start-forge-win32-x64\resources\app.asar\node_modules',
'C:\Users\oleksii.kurakin\WebstormProjects\electron-edge-js-quick-start-forge\out\electron-edge-js-quick-start-forge-win32-x64\resources\node_modules'
]
18:26:51.813 > baseNetAppPath: C:\Users\oleksii.kurakin\WebstormProjects\electron-edge-js-quick-start-forge\out\electron-edge-js-quick-start-forge-win32-x64\resources\net8.0
18:26:52.848 > Error: Unable to compile C# code.
----> Errors when compiling as a CLR library:
CS8021: No value for RuntimeMetadataVersion found. No assembly containing System.Object was found nor was a value for RuntimeMetadataVersion specified through options.
CS0518: Predefined type 'System.Void' is not defined or imported
CS0518: Predefined type 'System.Void' is not defined or imported
CS0518: Predefined type 'System.Boolean' is not defined or imported
CS0518: Predefined type 'System.Object' is not defined or imported
CS0518: Predefined type 'System.Object' is not defined or imported
CS0518: Predefined type 'System.String' is not defined or imported
CS0518: Predefined type 'System.String' is not defined or imported
CS0518: Predefined type 'System.Int32' is not defined or imported
CS0518: Predefined type 'System.Void' is not defined or imported
CS0518: Predefined type 'System.Object' is not defined or imported
CS0433: The type 'Guid' exists in both 'System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' and 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
CS0518: Predefined type 'System.String' is not defined or imported
CS0518: Predefined type 'System.Void' is not defined or imported
CS0518: Predefined type 'System.String' is not defined or imported
CS0518: Predefined type 'System.Void' is not defined or imported
CS0518: Predefined type 'System.Int32' is not defined or imported
CS0518: Predefined type 'System.Void' is not defined or imported
CS0518: Predefined type 'System.Object' is not defined or imported
CS0518: Predefined type 'System.Void' is not defined or imported
CS0518: Predefined type 'System.Void' is not defined or imported
CS0518: Predefined type 'System.Boolean' is not defined or imported
CS0518: Predefined type 'System.Object' is not defined or imported
CS0433: The type 'Task
As I mentioned in earlier earlier comments inline C# code does not work, comment out inline function and calls to it.
Yep you right.
It worked on my main system but when i tried on another windows without .net sdk i got that error
C:\Users\admin\Desktop\electron-edge-js-quick-start-forge-win32-x64>
19:39:57.966 > framework: Core
19:39:57.977 > NODE_PATH: undefined
19:39:57.978 > EDGE_USE_CORECLR: 1
19:39:57.979 > [
'C:\Users\admin\Desktop\electron-edge-js-quick-start-forge-win32-x64\resources\app.asar\node_modules',
'C:\Users\admin\Desktop\electron-edge-js-quick-start-forge-win32-x64\resources\node_modules'
]
19:39:58.003 > Error: CoreClrEmbedding::Initialize - Could not find any runtimeconfig file ([appname].runtimeconfig.json in app folder nor dotnet.runtimeconfig.json in sdk folder)
at process.func [as dlopen] (node:electron/js2c/node_init:2:2559)
at Module._extensions..node (node:internal/modules/cjs/loader:1602:18)
at Object.func [as .node] (node:electron/js2c/node_init:2:2559)
at Module.load (node:internal/modules/cjs/loader:1295:32)
at Module._load (node:internal/modules/cjs/loader:1111:12)
at c._load (node:electron/js2c/node_init:2:16955)
at Module.require (node:internal/modules/cjs/loader:1318:19)
at require (node:internal/modules/helpers:179:18)
at Object.
EDIT: This would happen on a system with .NET Runtime without .NET SDK when you are running non-published .NET library. Make sure that you copied your published .NET lib to resources\net.8.0
. It should contain coreclr.dll
and clrjit.dll
.
If you have a system with .NET Runtime but without SDK then there is no need to publish .NET library, remove inline C# code or convert dynamic
to IDictionary
although published project should have worked.
Perhaps you did not use output from dotnet publish
on that system in you net8.0 path.
See recently addressed issue https://github.com/agracio/edge-js/issues/226.
New edge-js
and electron-edge-js
release allows you to run binaries on systems that have .NET Runtime without SDK.
All you need to do is include <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
in your .csproj to generate runtime config during build.
Just to be clear a published library without runtimeconfig.json will also work but there is no need to do that.
Easiest way to determine if you have a published .NET library: check for coreclr.dll
and clrjit.dll
in you .NET output folder. In this case it should be under resources\net.8.0
.
Double checked on my system with .NET Runtime and without .NET Runtime in both cases published project runs correctly.
Hm, okay i'll try to check that with different approaches that you suggested, thank you. So just to be sure that i get everything right, do we need any other installations on users system to run builded electron project?
There is one requirement mentioned in readme: MS Visual C++ Redistributable.
As for publishing Edge.js Electron apps to another system here are some scenarios.
dotnet publish PathToSolution.sln --self-contained -r arch -c Release
.[appname].runtimeconfig.json
in root folder generated using <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
.csproj property.
Only one[appname].runtimeconfig.json
can exist in root.
Framework identifier in [appname].runtimeconfig.json
should correspond to deployed .NET Runtime.[appname].runtimeconfig.json
will be ignored.Issue with inline C# code is now fixed, update the project and re-run dotnet publish
I applied procedure from your read.me, on my pc is ok, but when i test electron-edge-js-quick-start-forge.exe on different Win10 PC i have an error and application don't run. My error is:
F:\electron-edge-js-quick-start-forge-win32-x64> 18:01:16.790 > framework: Core 18:01:16.802 > NODE_PATH: undefined 18:01:16.803 > EDGE_USE_CORECLR: 1 18:01:16.804 > [ 'F:\electron-edge-js-quick-start-forge-win32-x64\resources\app.asar\node_modules', 'F:\electron-edge-js-quick-start-forge-win32-x64\resources\node_modules' ] 18:01:16.854 > baseNetAppPath: F:\electron-edge-js-quick-start-forge-win32-x64\resources\net8.0 18:01:16.857 > TypeError: edge.initializeClrFunc is not a function at exports.func (F:\electron-edge-js-quick-start-forge-win32-x64\resources\node_modules\electron-edge-js\lib\edge.js:177:17) at Object. (F:\electron-edge-js-quick-start-forge-win32-x64\resources\app.asar\app.js:31:36)
at Module._compile (node:internal/modules/cjs/loader:1484:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1564:10)
at Module.load (node:internal/modules/cjs/loader:1295:32)
at Module._load (node:internal/modules/cjs/loader:1111:12)
at c._load (node:electron/js2c/node_init:2:17025)
at Module.require (node:internal/modules/cjs/loader:1318:19)
at require (node:internal/modules/helpers:179:18)
at Object. (F:\electron-edge-js-quick-start-forge-win32-x64\resources\app.asar\main.js:3:16)
Can you Help Me Please?