.net core Electron和edge.js使用.NET core DLL时出现错误
经过几天的努力和谷歌搜索,我决定尝试在这里找到一个解决方案 该项目使用electron edge js以及electron和angular for UI 我构建了一个netcoreapp2.0 dll-非常基本:.net core Electron和edge.js使用.NET core DLL时出现错误,.net-core,electron,edge.js,.net Core,Electron,Edge.js,经过几天的努力和谷歌搜索,我决定尝试在这里找到一个解决方案 该项目使用electron edge js以及electron和angular for UI 我构建了一个netcoreapp2.0 dll-非常基本: namespace ParserLibrary { public class Parser { public string GetText() { return "test"; } } }
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")]
});
如果我注释掉与解析器相关的行,它运行良好。
我在这里遗漏了什么?或者edge不支持像那样使用自定义dll?据我所知,edge从package.json中提取dll。如果将移动到根文件夹中,然后执行
引用:['DataParser.dll']
它应该可以工作;)当您构建electron for release时,您必须使用app.getAppPath()
作为基础。dll与主节点位于同一文件夹中,但您是否根据我的建议更改了代码?此外,node.js条目文件可能位于任何位置,重要的是package.json,因为它是您的应用程序路径。您解决了这个问题吗?我有点陷入了一个类似的问题,如果你能提供一个答案,我会很高兴:)tnx在advance@bnxuq再也记不清了——我最终放弃了使用binaryjs读取/解析文件的.net集成和用户节点。我认为您必须在DLL中使用任务调用(对象输入)进行整个启动,因此您必须为边缘构建特殊的DLL,而不能使用公共/共享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"