사용자 도구

사이트 도구


develop:node:edgejs

nodejs에서 c# dll 연동하기 (edgejs)

.net dll 테스트코드

  1. 파일명 : Sample105.cs
     
    using System.Threading.Tasks;
    namespace Sample105
    {
     public class Startup
     {
      public async Task<object> Invoke(object input)
      {
       return this.Add7((int)input);
      }
    
    
      int Add7(int v) 
      {
       return Helper.Add7(v);
      }
     }
    
    
     static class Helper
     {
      public static int Add7(int v)
      {
       return v + 7;
      }
     }
    }

C# source Code Compile

  1. command 명령어로 library compile 을 한다.
    E:\dev>"C:\Program Files (x86)\MSBuild\14.0\Bin\amd64\csc.exe" /target:library /debug Sample105.cs

node 설치

  1. node install 명령으로 node_module 를 설치한다.
    E:\dev> npm install edge-js 

node sourceCode

  1. 파일명 : edgeCall.js
    var edge = require('edge-js');
    
    var add5 = edge.func('Sample105.dll');
    
    add5(22, function (error, result) {
     if(error) throw error;
     console.log(result);
    });

edge-js 로 C# dll 호출하기

  1. node 명령을 실행한다.
    E:dev> node edgeCAll.js
    29

참고링크

develop/node/edgejs.txt · 마지막으로 수정됨: 2019/09/06 02:11 저자 starlits