gpt4 book ai didi

c# - Electron-Edge-JS App.config

转载 作者:太空宇宙 更新时间:2023-11-03 12:11:32 25 4
gpt4 key购买 nike

我正在使用 electron-edge-js 调用 C# DLL。

在 DLL 中,调用 App.config 文件以获取服务器连接信息。

return (ServiceDetailConfiguration)ConfigurationManager.GetSection(ServiceDetailConfiguration.ServiceDetailConfigurationConst);

在我调用dll的js文件中,可以成功调用到dll,并处理信息。也就是说,在我点击上面的行之前,我会抛出一个 null 异常,因为它找不到 app.config。

我试过以下方法:

Load WCF app.config bindings in edge.js app

working with electron-edge-js for existing dll with app.config

运气不好。

在我的 package.json 文件中,名称是“firstelectronapp”。当我构建文件时,我将其输出为“test.exe”

所以我尝试将这些文件放在与 test.exe 文件相同的根文件夹中,但没有成功:

  • first.exe.config
  • firstelectronapp.exe.config
  • 测试.exe.config
  • node.exe.config

有什么我想念的吗?我用一个调用 dll 的 app.config 编写了一个快速的 C# 应用程序,当逐步执行它时,我可以告诉这就是问题所在。

最佳答案

配置文件应重命名为 electron.exe.config 并放置在与 electron.exe 相同的目录中 - 即 node_modules\electron\dist

我只是在需要添加 bindingRedirect 时遇到了这个问题。把它放在上面的文件中就解决了。

此外,如果您使用 electron-builder 来打包应用程序,则可以通过将配置文件添加到构建配置中的 extraFiles 集合中,轻松地将配置文件包含在打包的应用程序中,例如:

"extraFiles": [
{
"from": "app.config",
"to": "my-electron-app-name.exe.config"
}
]

关于c# - Electron-Edge-JS App.config,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52061758/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com