问题
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.
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?
回答1:
As discussed by Hanselman in his blog. Host your own NuGet Server.
My personal preference is a Choco Nuget Server.
- Setup your NuGet Server
- Add your xlls to some folder
Pack your files with NuGet
nuget pack -version 0.0.1
Push your NuGet Package up to the server
nuget push -source \mycompany\repo\ mypackage.1.0.0.nupkg
Recommended Remove any user credentials such as passwords or usernames
回答2:
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.
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.
e.g.
<Name>-AddIn-packed.xll
<Name>-AddIn-packed.xll.config
<Name>-AddIn64-packed.xll
<Name>-AddIn64-packed.xll.config
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.
来源:https://stackoverflow.com/questions/52735817/excel-dna-add-in-with-connection-strings-stored-in-external-configuration-file