I have 2 windows forms in a solution and want to read some values from the respective config files of each app.
The second form is like an ‘option/tool’ from the first form. So in first form, I do:
someEventOfForm1...
{
Form2 f = new Form2();
f.ShowDialog();
}
Now, when ‘f’ tries to read from its config file, it ends up reading config file of first form. I want f to read its own config file.
- What should one do in such a scenario?
- Is it a bad design to open another form from one?
You can have only one application configuration file per application. Put the configuration settings for the project containing Form2 into the app.config file in the project containing Form1.
Not necessarily – it’s often a fundamental strategy for creating multi-window applications.