Manu v
Manu v

Reputation: 51

use .net dll in electron

I am a .NET developer and new to electron and node.js.

From my electron application, I need to call one function inside a .NET class library DLL which will generate some document and will send to print.

I need to use this electron application only on the windows machine. I see plugin Edge.js, but am not sure this will work for me and also don't know how to include in my project.

Upvotes: 5

Views: 5572

Answers (1)

Michael
Michael

Reputation: 684

Edge.js will do the trick.

See the following snippet:


    var edge = remote.require('electron-edge');

    var toErMahGerd = edge.func({
         assemblyFile: 'ERMAHGERD.dll',
         typeName: 'ERMAHGERD.Translate',
         methodName: "ToErMahGerd"
    });
    
    document.getElementById("translate-btn").addEventListener("click", function (e) { 
         var inputText = document.getElementById("input-text").value;
    
         toErMahGerd(inputText, function (error, result) {
              document.getElementById("output-text").innerHTML = result; 
         }); 
    });

And here is the GitHub-repo with not only good docs to dive in but a simple getting started.

Upvotes: 6

Related Questions