惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Y
Y Combinator Blog
Blog — PlanetScale
Blog — PlanetScale
H
Hackread – Cybersecurity News, Data Breaches, AI and More
WordPress大学
WordPress大学
B
Blog RSS Feed
A
About on SuperTechFans
V
Visual Studio Blog
J
Java Code Geeks
U
Unit 42
人人都是产品经理
人人都是产品经理
Martin Fowler
Martin Fowler
Recent Announcements
Recent Announcements
M
MIT News - Artificial intelligence
IT之家
IT之家
The Cloudflare Blog
T
The Blog of Author Tim Ferriss
C
Check Point Blog
博客园 - 叶小钗
P
Proofpoint News Feed
Microsoft Security Blog
Microsoft Security Blog
B
Blog
S
SegmentFault 最新的问题
Microsoft Azure Blog
Microsoft Azure Blog

博客园 - 后凤凰

nodejs在linux系统调用lazarus编辑的so文件 node使用koffi load dll卡死 Tencoding with out BOM lazarus配置记录 lazarus fastreport导出pdf Cant swap font ubuntu20.10安装scrcpy 背诵小鹤双拼 FireBird DataType TFDManager不能在Dll中创建线程池 cxGrid导出到图片 delphi安装package时无法定位程序输入点bpl Delphi fastreport乱码处理 electron14之后版本使用remote - 后凤凰 - 博客园 electron-edge-js编译 - 后凤凰 - 博客园 delphi 10.4.2 启动时报错 socket error go特点 Delphi Records与classes几点不同 electron 14 remote使用 - 后凤凰 anbox
elecron调用C#dll
后凤凰 · 2021-11-23 · via 博客园 - 后凤凰
const edge = require('electron-edge-js');
const log=require('electron-log');
// 定义方法
var Call = edge.func({
    // assemblyFile为dll路径
    assemblyFile: './dll/demofun.dll',
    // Client为命名空间,CallCallService类名
    typeName: 'demofun.Main',   
    // Call为方法名
    methodName: 'Call'      
});  

module.exports={
    Call,
} 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace demofun
{
    public class Main
    {
        /// <summary>
        /// 前端调用后端开放接口,封装给nodejs调用
        /// C#中,方法必须用async异步修饰,且返回值必须为Task<object>,其中,request即为方法的参数
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task<object> Call(object request)
        {
            //方法体
            return request;
        }
    }
}
 

electron 调用时使用的是 electron-edge-js
edge-js可以调用预先编译
对不同版本的electron需要预先编辑 edge_coreclr.node edge_nativeclr.node
在这个目录下
nodemodules/electron-edge-js/lib/native/win2/electron版本号/