Excel-DNA外接程序,其连接字符串存储在外部配置文件中 [英] Excel-DNA Add-In with connection strings stored in external configuration file

查看:103
本文介绍了Excel-DNA外接程序,其连接字符串存储在外部配置文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个项目中使用 Excel-Dna ,该项目中的连接字符串存储在名为 connections.config 的外部文件中,该文件在 App中引用.config 文件.生成项目时,两个配置文件都被复制到bin文件夹中,并且 App.config 文件被重命名为< Name> -AddIn64-packed.xll.config 应该是.

I'm using Excel-Dna in a project where connection strings are stored in an external file called connections.config, which is referenced in the App.config file. When building the project, both config files are copied to the bin folder and the App.config file is renamed <Name>-AddIn64-packed.xll.config as it should be.

问题在于打包的 xll 仍然依赖于两个配置文件.将连接字符串直接包含在 App.config 中时,一切工作正常,但是我需要将其保留在源代码之外.

The problem is that the packed xll still relies on both config files. Everything works fine when including the connection strings directly in the App.config, but I need to keep them outside of the source code.

有关如何进行的任何想法?

Any thoughts on how to proceed?

推荐答案

Excel-DNA当前不通过上的 configSource 支持 App.config 外部配置设置如果主.config文件+外部文件实际上不存在于压缩的 XLL所在的文件夹中,则-packed XLL.

Excel-DNA currently does not support App.config external configuration settings via configSource on -packed XLLs if the main .config file + external file is not physically present in the folder where the -packed XLL is.

如果要使用 configSource ,则必须将这些外部文件与打包的 XLL放在同一文件夹中.

If you want to use configSource in your case, you'll have to keep these external files together with the -packed XLL, on the same folder.

例如

  • < Name> -AddIn-packed.xll
  • < Name> -AddIn-packed.xll.config
  • < Name> -AddIn64-packed.xll
  • < Name> -AddIn64-packed.xll.config
  • connections.config

或者,如果您希望将连接字符串保存在外部文件中,但仍嵌入在-包装 XLL中,则完全不要使用 configSource ,将 connections.config 添加为程序集的嵌入式资源,然后

As an alternative, if you want to have the connection strings on an external file, but still embedded within the -packed XLL, then do not use configSource at all, add your connections.config as an embedded resource of your assembly, and read your connection strings from there.

这篇关于Excel-DNA外接程序,其连接字符串存储在外部配置文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆