C# 如何在node.js应用程序中调用dll方法?(参数计数不匹配)

C# 如何在node.js应用程序中调用dll方法?(参数计数不匹配),c#,node.js,dll,edgejs,C#,Node.js,Dll,Edgejs,我正在尝试使用node.js应用程序中的c.dll。我正在使用来实现这一点 我可以加载dll,但无法调用其方法。 我得到的错误是 错误:参数计数不匹配。 匿名电话:1:55 如果有人能解释边缘绑定/参数传递是如何工作的,我们将不胜感激 dll代码: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; namespace P

我正在尝试使用node.js应用程序中的c.dll。我正在使用来实现这一点

我可以加载dll,但无法调用其方法。 我得到的错误是

错误:参数计数不匹配。 匿名电话:1:55

如果有人能解释边缘绑定/参数传递是如何工作的,我们将不胜感激

dll代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Diagnostics;

namespace PortableClassLibrary1
{
    public class Class1
    {
        public String helloworld(){
            Debug.WriteLine("Hello dll world");  
            return("Hello dll World!");
        }

    }
}
下面是我的Simplied node.js代码:

"use strict";
const express = require("express");
const router = express.Router();
const { Console } = require("console");

router.get("/", (req, res) => {
 var edge = require("edge-js");
  var helloDll = edge.func({
    assemblyFile: "bin/PortableClassLibrary1.dll",
    typeName: "PortableClassLibrary1.Class1",
    methodName: "helloworld",
  });
  helloDll(null, function (error, result) {
    if (error) throw error;
    console.log(result);
  });

});


module.exports = router;
我还尝试了同步调用:

  var returnResult = helloDll(true);
  var returnResult = helloDll(null, true);
同样的结果

我查看了这些链接,但没有任何帮助


那怎么样?任何知道如何在dll中使用edge js调用.dll方法的人都应该返回任务并接受输入参数

我修改了代码如下,它为我工作

    public async Task<object> helloworld(dynamic input)
    {
        Debug.WriteLine("Hello dll world");
        // Ignore the compiler warning about await keyword as this just a demo code..
        return "Hello from.NET world !!";
    }

您正在调用一个实例方法。您需要一个实例来调用它,该实例很可能是缺少的参数—不知道该实例如何使用此库。尝试将其设置为静态方法,然后查看发生了什么我将其设置为静态,并得到了不同的错误:System.InvalidOperationException无法访问CLR方法以通过反射进行包装。确保它是公共实例方法