tjanczuk / edge

Run .NET and Node.js code in-process on Windows, MacOS, and Linux
http://tjanczuk.github.io/edge
Other
5.42k stars 640 forks source link

edge-cs.dll cannot be loaded in electron app when packaged in asar #411

Closed kneumei closed 2 days ago

kneumei commented 8 years ago

Not sure if this is the right place to ask this question, but I'm trying to use edge in my electron app (using https://github.com/kexplo/electron-edge). Everything works fine when I run the app unpackaged, however when I package the app into an asar file, I see

Error: Could not load file or assembly 'file:///C:\app\v0.36.2\win32-x64\…s\app.asar\node_modules\electron-edge\node_modules\edge-cs\lib\edge-cs.dll' or one of its dependencies. The system cannot find the file specified.
    at Error (native)
    at Object.exports.func (C:\app\v0.36.2\win32-x64\resources\app.asar\node_modules\electron-edge\lib\edge.js:157:17)

I've found other threads (https://github.com/atom/electron/issues/1802, for example) saying that I need to unpack the dlls. I did that, but still seeing the errors. I'm thinking that whatever loads edge-cs.dll needs to know to look in the unpacked folder?

JoaoGabrielDePaula commented 7 years ago

Me too. I am with this problem!

node_modules\edge-cs is not packed into asar archive - contains executable code node_modules\electron-edge is not packed into asar archive - contains executable code

What I do?

adairborba commented 7 years ago

Too. Same error.

HZSamir commented 7 years ago

Same issue here as well. Really hoping for a fix.

HZSamir commented 7 years ago

Well it seems there is a solution after all, thanks to this To fix this, I went inside my node_modules folder, deleted the edge-cs folder and replaced it with edge-asar-cs, after that I renamed this new folder edge-asar-cs into edge-cs and it worked.

I hope this helps someone else. Good evening.

Augus commented 6 years ago

I hope this helps someone else.

change edge-cs/lib/edge-cs.js, add .replace('app.asar', 'app.asar.unpacked')

var path = require('path');

exports.getCompiler = function () {
    return process.env.EDGE_CS_NATIVE || (process.env.EDGE_USE_CORECLR ? 'Edge.js.CSharp' : path.join(__dirname, 'edge-cs.dll').replace('app.asar', 'app.asar.unpacked'));
};

exports.getBootstrapDependencyManifest = function() {
    return path.join(__dirname, 'bootstrap', 'bin', 'Release', 'netstandard1.6', 'bootstrap.deps.json');
}

change electron-packager asar propertiy

"asar":{
        "unpackDir": "node_modules/edge-cs/**"
},
hohks12 commented 6 years ago

@Augus can you clarify what you mean by 'change electron-packager asar propertiy' ? I can't find which file to make this change.

josiahbryan commented 6 years ago

Same, what exactly do I need to change? 😁

Augus commented 6 years ago

@hohks12 https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#asar

Dyinfalse commented 5 years ago

@Augus I am logged in just to give you a compliment

calebbergman commented 5 years ago

change electron-packager asar propertiy

"asar":{ "unpackDir": "node_modules/edge-cs/**" }

You can also add it as a command line argument: electron-packager --asar.unpackDir=node_modules/edge-cs/**