How to find path of active app.config file?

后端 未结 8 2036
被撕碎了的回忆
被撕碎了的回忆 2020-12-02 04:43

I\'m trying to finish this exception handler:

if (ConfigurationManager.ConnectionStrings[\"ConnectionString\"]==null)
{
    string pathOfActiveConfigFile = .         


        
8条回答
  •  心在旅途
    2020-12-02 05:30

    The first time I realized that the Unit testing project referenced the app.config in that project rather then the app.config associated with my production code project (off course, DOH) I just added a line in the Post Build Event of the Prod project that will copy the app.config to the bin folder of the test project.

    Problem solved

    I haven't noticed any weird side effects so far, but I am not sure that this is the right solution, but at least it seems to work.

提交回复
热议问题