0
我在我的TestProject中有一個app.config文件,但是當我嘗試使用ConfigurationManager讀取它時,它從別處讀取,它不是我的app.config。如何糾正?Visual Studio 2008自動化測試項目可以讀取配置文件,如app.config? (C#.NET)
當前配置:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="Production" connectionString="Server=127.0.0.1,2345;Uid=user;Pwd=password;Initial Catalog=DATABASE_DATA"/>
</connectionStrings>
</configuration>
當前代碼:
ConfigurationManager.ConnectionStrings[0].ConnectionString
預期輸出:
"Server=127.0.0.1,2345;Uid=user;Pwd=password;Initial Catalog=DATABASE_DATA"
實際輸出:
"data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"