edge icon indicating copy to clipboard operation
edge copied to clipboard

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

Open kneumei opened this issue 8 years ago • 10 comments

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?

kneumei avatar Apr 02 '16 05:04 kneumei

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?

JoaoGabrielDePaula avatar Oct 20 '16 15:10 JoaoGabrielDePaula

Too. Same error.

adairborba avatar Oct 21 '16 11:10 adairborba

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

HZSamir avatar Nov 29 '16 14:11 HZSamir

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.

HZSamir avatar Nov 29 '16 15:11 HZSamir

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/**"
},

Augus avatar Jun 14 '18 08:06 Augus

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

hohks12 avatar Aug 22 '18 02:08 hohks12

Same, what exactly do I need to change? 😁

josiahbryan avatar Sep 12 '18 17:09 josiahbryan

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

Augus avatar Sep 13 '18 03:09 Augus

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

Dyinfalse avatar Jan 28 '19 11:01 Dyinfalse

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/**

calebbergman avatar May 15 '19 19:05 calebbergman