0
我有一個C#控制檯應用程序,例如Project1
。一種方法使用如下設置。調用另一個使用Properties.Settings.Default的exe文件的方法
void Method1() {
var x = Properties.Settings.Default.XXXX;
}
用戶可以更改Project1.exe.config
中的值,並且該方法獲取了更改的值。
現在我需要在同一個解決方案中創建一個新的控制檯項目,例如Project2
,新項目在添加引用後調用方法Project1.Method1()
。但是,它總是得到默認值。我試圖
- 添加設置
XXXX
在Project2
和Project2.exe.config
改變的值。
Project2.exe.config:
<applicationSettings>
<Project2.Properties.Setting>
<settings name="XXXX" serializeAs="String">
<value>....</value>
- 複印
Project1.exe.config
到的Project2
的bin \ debug文件夾和改變複製Project1.exe.config
的設置。
兩者都不工作。什麼是正確的做法?
我做到了。但它不會在'Project1.exe.config'中得到更改的值。 – ca9163d9
'Project2.exe'不會從'project1.exe.config'中讀取。您需要將配置設置從'project1.exe.config'複製到'project1.exe.config'並將其更改爲_there_。 –
我的'Project1.exe.config'和'Project2.exe.config'都包含代碼' .... ' –
ca9163d9