문제

I am attempting to use this code:

 String MainDB = ConfigurationManager.AppSettings["MainDB"];
 MessageBox.Show(MainDB);
 String MailInfo = ConfigurationManager.AppSettings["MailInfo"];
 MessageBox.Show(MailInfo);
 String HousingIndexLocation = ConfigurationManager.AppSettings["HousingIndex"];
 MessageBox.Show(HousingIndexLocation);

to access values generated by this screen:

enter image description here

Everytime the values are returned null.

what am I missing in my implementation of these settings?

도움이 되었습니까?

해결책

Try

String MainDB = Properties.Settings.Default.MainDB;
MessageBox.Show(MainDB);
String MailInfo = Properties.Settings.Default.MailInfo;
MessageBox.Show(MailInfo);
String HousingIndexLocation = Properties.Settings.Default.HousingIndex;
MessageBox.Show(HousingIndexLocation);

다른 팁

You're getting an error because ConfigurationManager is not the proper way to access properties stored in those files. Take a look at:

Using Settings in C#

Long story short, you access the settings in the Settings file using the Properties namespace:

Properties.Settings.Default.MainDB;
// And so on...
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top