Giter Site home page Giter Site logo

Comments (22)

IhorKrupinEmpeek avatar IhorKrupinEmpeek commented on August 16, 2024 7

Iā€™m experiencing the same issue as @grofit
Same steps on Windows 10 x64.
require(edgeNative) in edge.js returns '{}'

from electron-edge-js-quick-start.

JonathanLydall avatar JonathanLydall commented on August 16, 2024 2

I'm getting the exact same error, but I've found out something which seems to help a bit so I'm hoping it can lead someone else here to find a solution to the problem.

The Quickstart worked for me, but when I made a new project using Visual Studio 2017, it wouldn't work until I added <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> to my .csproj file, to make it look like:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Library</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="EdgeJs" Version="9.3.4" />
  </ItemGroup>

</Project>

I'm still struggling though because that doesn't fix my existing project which has been running fine on Edge for a long time, but we're now trying to migrate it to .NET Core.

Will post if I work out more.

from electron-edge-js-quick-start.

vadi2 avatar vadi2 commented on August 16, 2024

I'm not sure if this fixes it or just hides the error, but doing the following:

const baseNetAppPath = path.join(__dirname, '/src/QuickStart.Core/bin/Debug/netcoreapp2.0');

process.env.EDGE_USE_CORECLR = 1;
process.env.EDGE_APP_ROOT = baseNetAppPath;

const edge = require('electron-edge-js');

var baseDll = path.join(baseNetAppPath, 'QuickStart.Core.dll');

var getAppDomainDirectory = edge.func({
    assemblyFile: baseDll,
    typeName: 'QuickStart.Core.LocalMethods',
    methodName: 'GetAppDomainDirectory'
});

now gives:

 JavaScript error occurred in the main process
Uncaught Exception:
Error: Could not load type 'QuickStart.Core.LocalMethods'
    at Object.exports.func (/home/vadi/Programs/electron-edge-js-quick-start/node_modules/electron-edge-js/lib/edge.js:181:17)
    at Object.<anonymous> (/home/vadi/Programs/electron-edge-js-quick-start/main.js:27:34)

from electron-edge-js-quick-start.

agracio avatar agracio commented on August 16, 2024

Have you followed provided instructions? First do npm install and only then compile .sln? QuickStart.Core references dlls inside electron-edge-js folder and copies them to build output.

from electron-edge-js-quick-start.

vadi2 avatar vadi2 commented on August 16, 2024

Yes, I did npm install first - see log above. Here's how the folder with the dlls looks like:

$ ls /home/vadi/Programs/electron-edge-js-quick-start/src/QuickStart.Core/bin/Debug/netcoreapp2.0
EdgeJs.dll                         Microsoft.CodeAnalysis.CSharp.Workspaces.dll       Microsoft.DotNet.InternalAbstractions.dll  QuickStart.Core.dll                     System.Composition.Hosting.dll
EdgeJs.pdb                         Microsoft.CodeAnalysis.dll                         Microsoft.DotNet.PlatformAbstractions.dll  QuickStart.Core.pdb                     System.Composition.Runtime.dll
ExternalLibrary.dll                Microsoft.CodeAnalysis.VisualBasic.dll             Microsoft.Extensions.DependencyModel.dll   refs                                    System.Composition.TypedParts.dll
ExternalLibrary.pdb                Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll  Newtonsoft.Json.dll                        System.Composition.AttributedModel.dll
Microsoft.CodeAnalysis.CSharp.dll  Microsoft.CodeAnalysis.Workspaces.dll              QuickStart.Core.deps.json                  System.Composition.Convention.dll

Is it correct?

from electron-edge-js-quick-start.

radencode avatar radencode commented on August 16, 2024

I am getting the same error:

TypeError: edge.initializeClrFunc is not a function at Object.exports.func (C:\Users\Jenster\Desktop\Development\reflow\reflow-client\current\release\Reflow-win32-x64\resources\app.asar\node_modules\electron-edge-js\lib\edge.js:182) at A.edgeInit (main.bundle.effe34fd3444d7d46fc7.js:1) at new A (main.bundle.effe34fd3444d7d46fc7.js:1) at new e (main.bundle.effe34fd3444d7d46fc7.js:1) at constructClassInstance (main.bundle.effe34fd3444d7d46fc7.js:1) at beginWork (main.bundle.effe34fd3444d7d46fc7.js:1) at n (main.bundle.effe34fd3444d7d46fc7.js:1) at o (main.bundle.effe34fd3444d7d46fc7.js:1) at i (main.bundle.effe34fd3444d7d46fc7.js:1) at Q (main.bundle.effe34fd3444d7d46fc7.js:1)

Here are the versions that I am using:

Electron: 2.0.2 Node: 8.9.3 electron-edge-js: 8.3.6

I am using the same configuration with edge-js and it works perfectly, however when I use electron-edge-js and build the app with electron-builder it gives me the above error.

Did you guys find a fix for this? Am I doing something wrong?
I would really appreciate your help.

from electron-edge-js-quick-start.

vadi2 avatar vadi2 commented on August 16, 2024

Did you guys find a fix for this?

The issue is still there as you see, so I just created a command-line wrapper for my binary and just call it via Node.js's proces function to get the work done.

from electron-edge-js-quick-start.

agracio avatar agracio commented on August 16, 2024

Quick start does not cover electron-builder created apps. When you package with electron builder it is likely that the paths specified in process.env.EDGE_APP_ROOT are no longer valid. Try using console.log(process.env.EDGE_APP_ROOT) to determine the problems with path.

from electron-edge-js-quick-start.

agracio avatar agracio commented on August 16, 2024

@vadi2 electron-edge-js 8.3.6 has improvements for path handling, perhaps quick-start will work correctly on Linux. I have not had a chance yet to test it on Linux but it fixed issues on macOS. You can give it another try.

from electron-edge-js-quick-start.

agracio avatar agracio commented on August 16, 2024

Update: just tested on Ununtu 18.04, runs without any problems.

from electron-edge-js-quick-start.

radencode avatar radencode commented on August 16, 2024

@agracio process.env.EDGE_APP_ROOT is correct and I get the same error even if I don't use electron-builder it still gives me edge.initializeClrFunc is not a function

from electron-edge-js-quick-start.

agracio avatar agracio commented on August 16, 2024

Ok so just be be clear on the issue:
You cloned a fresh copy of this repo and have not done any changes to it. Followed the steps from README in correct order and after running npm start command got this error?
I have test the latest version on Windows/macOS/Linux and did not encounter any problems so far.

from electron-edge-js-quick-start.

radencode avatar radencode commented on August 16, 2024

from electron-edge-js-quick-start.

radencode avatar radencode commented on August 16, 2024

@agracio I figured out what my issue is: I am using webpack to bundle my react.js app and instead of C:\Users\Jenster\Desktop\Development\reflow\reflow-client\electron-edge-js-quick-start\lib the bundled path is lib Any idea how I can provide process.env.EDGE_APP_ROOT a relative path instead of absolute path?

from electron-edge-js-quick-start.

radencode avatar radencode commented on August 16, 2024

@agracio I fixed it. I put the path in node env variable in my electron main.js file and then picked it up in my react.js component. Anyway, thank you for maintaining this project and providing support for .Net Core 2.0. You are awesome, keep up the good work. ;)

from electron-edge-js-quick-start.

grofit avatar grofit commented on August 16, 2024

I just realised I am getting this issue on windows 10, here were my steps:

  • Fork then clone repo (you could just clone it directly)
  • run npm i
  • run dotnet build src/QuickStart.sln
  • run npm start:standard (get error)
  • run npm start (get other error)

from electron-edge-js-quick-start.

ukenny avatar ukenny commented on August 16, 2024

After troubleshooting this for work I may have found a work-around. If I download Release v2.2.4 with SDK 2.2.203 I get this same error. But if I use a global.json with my .net core project to force it to use an older version of the SDK (and rebuild the .net core project) I can successfully run my project without issues.

{
"sdk": {
"version": "2.2.202" }
}

Make sure you download the older version of the SDK you're forcing the project to use!

The only different seems to be that they added C# 8.0 support in Release 2.2.4. Can somebody who's had this issue try this and see if it fixes it for you?

from electron-edge-js-quick-start.

risikoruk avatar risikoruk commented on August 16, 2024

Like @grofit and @IhorKrupin mentioned, those precise steps do not make the standard .NET version work.

The core one works okay for me though. With the standard instead, I immediately get: Uncaught TypeError: edge.initializeClrFunc is not a function

Also, why is the start:standard crossed over in the ReadMe? Is it no longer working?

from electron-edge-js-quick-start.

agracio avatar agracio commented on August 16, 2024

Standard is crossed over because it is almost impossible to get it to work. To get to the bottom of the error try running https://github.com/agracio/edge-js-quick-start. Unlike Electron version it will display underlying error. The problem appears to be with dll versions for some of the references in .NET Standard project as some being imported from nuget with correct versions and some pulled in from your .NET Standard install folder that will have higher versions than requested by project. You might be able to solve it by changing the referenced versions in .csproj file.

from electron-edge-js-quick-start.

corylulu avatar corylulu commented on August 16, 2024

This is old, but I think I found the problem. After testing on 3 different systems and not being able to get it to initialize properly on Linux, I found that in deps_entry.cpp, the EDGE_PLATFORM_NIX was not being defined, and because of that, the nuget packages path resolutions weren't being lower cased. agracio/edge-js#101

Edit: Upon further investigation, I'm finding that the deps hash check just isn't valid. The .deps.json's "sha512" value simply doesn't match the "nkpkg.sha512" value on Linux... Should just be ignored if the versions match.

from electron-edge-js-quick-start.

rama-boddeda avatar rama-boddeda commented on August 16, 2024

HI @agracio ,
We ran the c# code by using edge-js in node. But I am facing above issue i.e edge.initializeClrFunc is not a function in Linux server , It's working in Windows PC. Can you please guide me for this.

from electron-edge-js-quick-start.

kaifa999 avatar kaifa999 commented on August 16, 2024

This problem is caused by the wrong version of node.js and electron, or your nodejs version is not pre-compiled, just change to the version of nodejs corresponding to the electron version.

from electron-edge-js-quick-start.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.