user3224611
user3224611

Reputation: 84

use edge in node js to bind a DLL library not successful

i try to learn how to use edge (a node.js module) to bind a pre-compiled DLL but it doesn't work in the right way...

my DLL is a really simple library and it has been tested multiple times in other .Net program. i wrote my DLL file in Jscript.Net:

import System;
import System.Console;
import System.IO;

package power{

    public class testp {

            function hello (){

            var time_1 = DateTime.Now;

            for (var i =0; i<10000; i++){

                Console.WriteLine ("hello world!");

            };

            var time_2 = DateTime.Now;

            Console.WriteLine (time_2-time_1);

            };

    };

};

it is really simple, the Hello() method will print out 10000 "hello world" in stdout;

i can call it in other of my Jscript.net programs by doing:

import System;
import System.Console;
import System.IO;
import power;

var pri = new testp;
pri.hello();

according to the official web, i have tried:

var edge = require("edge");

var clrMethod = edge.func({
    assemblyFile: 'power.dll',
    typeName: 'power.testp',
    methodName: 'hello'
});

clrMethod();

MY QUESTION: how can i call it in edge successfully?

Upvotes: 1

Views: 3171

Answers (1)

Lucio Paiva
Lucio Paiva

Reputation: 20736

As far as I know, Edge.js does not support JScript.NET. At least it doesn't mention it anywhere in the docs.

Have you tried the example in C#? The problem is that Edge.js demands that the exported method in the DLL must have a specific signature:

Func<object,Task<object>>

Certainly your DLL is not exporting the function with the correct signature and that is the reason it didn't work as you expected.

Upvotes: 1

Related Questions