25

i have an issue how to call sample .dll files into my Electron App. I have sample .dll files in my folder, the thing is how to access my sample.dll file and how to call my sample.dll function and gets results. Any tutorials or steps to follow please sample code to start

batMan007
  • 551
  • 1
  • 10
  • 24

2 Answers2

38

Calling into a .dll in Electron is no different to calling into one in plain NodeJS, which means you have two options, node-ffi or a native Node addon that links with your .dll and exposes a JavaScript API. If you decide to create a native Node addon you will need to build it to target Electron.

Here are some links that cover these topics:

Vadim Macagon
  • 14,463
  • 2
  • 52
  • 45
  • thanks for ur feedback every blog has different way of methods cant get proper results – batMan007 Sep 19 '16 at 09:58
  • 3
    Node FFI won't compile with Node versions greater than Node 8. The project doesn't seem to be maintained any more sadly, so expect node gyp to throw errors if you NPM install with recent Node versions :( – Malcolm Swaine Jun 27 '20 at 11:37
  • 1
    @Malcolm Swaine Thanks for mentioning! What can we do in that case? – poloapolo Jun 28 '20 at 17:15
  • 2
    @poloapolo I'm using ffi-napi now and it seems to be working out well. I've had issues trying to invoke method calls from the renderer context, but from the ipc context it's doing the job. Repo is here https://github.com/node-ffi-napi/node-ffi-napi – Malcolm Swaine Jun 29 '20 at 00:32
3

Electron-Edge helps to run .NET in Node.js on Electron.
You can find it on GitHub.
Here it is explained how to use dll files in it.(Scroll Down a little to find 'If you prefer to pre-compile your C# sources to a CLR assembly you can reference a CLR assembly from your Node.js code...'