Quantcast
Channel: User Jack - Stack Overflow
Viewing all articles
Browse latest Browse all 40

Error: A dynamic link library (DLL) initialization routine failed on electron but it's fine on node js

$
0
0

I'm trying to load a custom module in electron written in D with node_dlang package, which is fine with node, but it fails within electron.

the test with node, that runs just fine, goes like this:

const nativeModule = require('./module.node');const assert = require('assert');assert(nativeModule != null);assert(nativeModule.ultimate() == 42);

But when I went to use it within electron.js, through the preload script, it returns in an error.

the preload script goes like this:

const {    contextBridge,    ipcRenderer} = require("electron");const nativeModule = require('./module.node');const assert = require('assert');assert(nativeModule.ultimate() == 42);function pageLoaded(){   // ...}window.addEventListener('DOMContentLoaded', pageLoaded);

the error when I attempt to load the module within electron application is:

A JavaScript error occured in the browser process--------------------------- Uncaught Exception: Error: A dynamic link library (DLL) initialization routine failed.

\\?\C:\Users\001\Desktop\ele\module.node    at process.func [as dlopen] (VM70 asar_bundle.js:5)    at Object.Module._extensions..node (VM43 loader.js:1138)    at Object.func [as .node] (VM70 asar_bundle.js:5)    at Module.load (VM43 loader.js:935)    at Module._load (VM43 loader.js:776)    at Function.f._load (VM70 asar_bundle.js:5)    at Function.o._load (VM75 renderer_init.js:33)    at Module.require (VM43 loader.js:959)    at require (VM50 helpers.js:88)    at Object.<anonymous> (VM88 C:\Users\001\Desktop\ele\preload.js:6)

What's causing this and how do I fix this?

version

node version is: v14.17.0electron.js: v13.1.1

both are 64-bit.

the module source code goes like this:

import std.stdio : stderr;import node_dlang;extern(C):void atStart(napi_env env){    import std.stdio;    writeln ("Hello from D!");}int ultimate(){    return 42;}mixin exportToJs! (ultimate, MainFunction!atStart);

it's compiled with dub command line. No arguments.

UPDATE 1 Do I need to rebuild this module? I found this but it didn't work for me either. I installed the electron-rebuild package by npm install --save-dev electron-rebuild and rebuild with .\node_modules\.bin\electron-rebuild.cmd -v 13.1.1 the command ran fine but I still got same error.

UPDATE 2: inside the console, I clicked in the javascript source code file link in the error message (from the exception) it points to this line of code, where there's this comment saying that:

no static exports found

enter image description here

what does that mean? is this related to the methods in D class? they're marked as public... not sure if related


Viewing all articles
Browse latest Browse all 40

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>