如何从node.js文件调用C#dll文件中的函数 [英] How to call functions in a C# dll file from a node.js file

查看:250
本文介绍了如何从node.js文件调用C#dll文件中的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

**我创建了一个C#dll文件,其中包含返回一些值的函数,并且我试图从node.js文件中调用这些函数以获取这些值。

**I created a C# dll file that contains functions that returns some values, and I am trying to call these functions from a node.js file to get those values. Please how do I go about this?

推荐答案

我相信 Edge.js-您需要在Windows,macOS和Linux上在进程内运行.NET和Node.js代码。

I believe the Edge.js - Run .NET and Node.js code in-process on Windows, macOS, and Linux is what you need.

通过使用 Edge.js ,我们可以编写以下JavaScript代码来调用现有的C#程序。

By using Edge.js, we can write the following JavaScript codes that invoke existing C# programs.

var clrMethod = edge.func({
    assemblyFile: 'My.Edge.Samples.dll',
    typeName: 'Samples.FooBar.MyType',
    methodName: 'MyMethod' // This must be Func<object,Task<object>>
});

var clrMethod = edge.func('My.Edge.Samples.dll');

var add7 = edge.func(require('path').join(__dirname, 'add7.csx'));

以上三个示例代码均从其GitHub主页复制/粘贴。

The above three sample codes are all copy/pasted from their GitHub home page.

这篇关于如何从node.js文件调用C#dll文件中的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆