Accessing seperate Configuration file from a different project

  • Thread starter Thread starter labjac
  • Start date Start date
L

labjac

Guest
Hallo

We got an application that consist of three different parts, Core where we hold common classes for both the service project and the front end project.

We want to create a form to set the connection string in the core project to be shared by both the service project and the front end. (Service project doesn't have any forms).

Below how can we address and set the configuration files as per picture below. (Understand through the ConfigurationManager but for the rest I'm battling to find information.

The issue with the App.Config is that it get's recompiled between debug and release, and also when the program is unistalled and reinstalled. makes it difficult because we need to keep setting the app.config. The ConnectionString.config hopefully does change in the same manner as the app.config. (Understand the [projectName.exe.config] the compiler changes the app.config to the [projectName.exe.config] we trying to avoid this.

Below is just a simplification on what we trying to achieve.

namespace WCS_FrontEnd.Setup.GUI
{
public partial class frmSQL_Connections : Form
{
public frmSQL_Connections()
{
InitializeComponent();
}

private void frmSQL_Connections_Load(object sender, EventArgs e)
{
txtConnectionstring.Text = GetConnectionstring();
}



private string GetConnectionstring()
{
string connectionString = ; /// = Need to get the connectionString for the

/// WCS_Core.AppConfiguration.Connectionstring in key = Connectionstring

return connectionString;
}

private void btnSave_Click(object sender, EventArgs e)
{
SetConnectionstring(txtConnectionstring.Text);
}

private void SetConnectionstring(string Connectionstring)
{
/// Need to save to WCS_Core.AppConfiguration.Connectionstring in key = Connectionstring
}
}
}
1604210.jpg




labjac

Continue reading...
 
Back
Top