tjanczuk / edge

Run .NET and Node.js code in-process on Windows, MacOS, and Linux
http://tjanczuk.github.io/edge
Other
5.42k stars 641 forks source link

Getting TargetParameterCountException when calling a C# DLL #726

Closed AvaGanesh closed 5 months ago

AvaGanesh commented 2 years ago

Hi All, I have to call a function inside a DLL file and retrieve some data, I am having trouble while passing parameters.

public object Initialize(
      int type,
      string x,
      string y,
      string z,
      out object a,
      out object b,
      out object c,
      out object error)

js code

var getData  = edge.func({
                    assemblyFile: pathToDLL,
                    typeName:  namespace.className,
                    methodName: "Initialize"
});
var input = [2, 'x', 'y', 'z', -1, 'test', 'test', -1];

getData(input,function(error,result){
    if(error) throw error;
    console.log(result);
});

when the above function is error it throws System.Reflection.TargetParameterCountException

image

Is there a different way to pass out params? Any help on the above issue is much appreciated.

-Regards

agracio commented 5 months ago

Edge.js only supports C# methods with the following signature

public async Task<object> MyMethod(dynamic input)
{
    //return results sync/async;
}

You need to wrap your method in this signature and pass parameters as desribed here https://github.com/agracio/edge-js?tab=readme-ov-file#using-compiled-assembly.

Any new Issues should be raised in https://github.com/agracio/edge-js