【问题标题】:Electron-Edge-JS App.configElectron-Edge-JS App.config
【发布时间】:2018-08-28 15:43:19
【问题描述】:

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

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

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

在我调用dll的js文件中,我可以成功调出dll,并处理信息。也就是说,直到我点击上面的行,我得到一个空异常,因为它找不到 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
  • test.exe.config
  • node.exe.config

我有什么遗漏吗?我用调用 dll 的 app.config 编写了一个快速 C# 应用程序,当单步执行它时,我可以看出问题所在。

【问题讨论】:

    标签: c# node.js electron app-config edgejs


    【解决方案1】:

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

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

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

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

    【讨论】:

      猜你喜欢
      • 2018-05-30
      • 1970-01-01
      • 2022-06-21
      • 2021-11-26
      • 1970-01-01
      • 2017-08-27
      • 2021-02-08
      • 2018-01-23
      • 2023-02-05
      相关资源
      最近更新 更多