0

经过几天的尝试和谷歌搜索,我决定尝试在这里找到解决方案。

该项目使用 electron-edge-js 与电子和角度的 UI。

我构建了一个 netcoreapp2.0 dll - 非常基本:

namespace ParserLibrary
{
    public class Parser
    {
        public string GetText()
        {
            return "test";
        }
    }
}

像这样使用:

var getCurrentTime = edge.func({
    source: function() {/*
    using System;
    using System.Threading.Tasks;
    using ParserLibrary;

    public class Startup
    {      
        public Parser parser = new Parser();
        public async Task<object> Invoke(object input)
        {
            return parser.GetText();
        }
    }
*/},
    references: [path.join(__dirname, "DataParser.dll")]
});

但这是我运行电子时最终遇到的错误

"Unable to compile C# code.
----> Errors when compiling as a CLR library:
c:\Users\**\AppData\Local\Temp\xwlkiee0.0.cs(8,16) : error CS0012: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
----> Errors when compiling as a CLR async lambda expression:
c:\Users\**\AppData\Local\Temp\rf0qpqan.0.cs(5,42) : error CS1513: } expected
c:\Users\**\AppData\Local\Temp\rf0qpqan.0.cs(20,9) : error CS1519: Invalid token 'return' in class, struct, or interface member declaration
c:\Users\**\AppData\Local\Temp\rf0qpqan.0.cs(20,35) : error CS1001: Identifier expected
c:\Users\**\AppData\Local\Temp\rf0qpqan.0.cs(22,1) : error CS1022: Type or namespace definition, or end-of-file expected
c:\Users\**\AppData\Local\Temp\rf0qpqan.0.cs(10,18) : error CS0542: 'Startup': member names cannot be the same as their enclosing type"

如果我注释掉与 Parser 相关的行,它运行良好。我在这里缺少什么 - 或者边缘并不真正支持使用这样的自定义 dll?

4

0 回答 0