Can't call method inside C# DLL from node service using Edge.js

浪子不回头ぞ 提交于 2020-12-12 10:12:46

问题


I am playing with the Edge.js and were able to run most of the examples but when it comes to using compiled C# dll file, I couldn't get it working.

My node.js code is

var clrMethod = edge.func({
    assemblyFile: 'C:\\Users\\hello\\Desktop\\Debug\\DemoClass.dll',
    typeName: 'DemoClass',
    methodName: 'Invoke' 
});

clrMethod(8, function (error, result) {
    if (error) {
        console.log(error);
        throw error;
    }

    console.log(result);
});

C# DLL code is

using System.Threading.Tasks;

namespace DemoClass
{
    public class Startup
    {
        public async Task<object> Invoke(object input)
        {
            int v = (int)input;
            return Helper.AddSeven(v);
        }

        static class Helper
        {
            public static int AddSeven(int v)
            {
                return v + 7;
            }
        }
    }
}

When trying with the above code it silently passed through the node.js script and doesn't log any result or error. Can someone please guide.

Thanks

来源:https://stackoverflow.com/questions/59841697/cant-call-method-inside-c-sharp-dll-from-node-service-using-edge-js

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!