Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7794701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:51:03+00:00 2026-06-01T22:51:03+00:00

I made an application that is able to change its app.config (the connection string

  • 0

I made an application that is able to change its app.config (the connection string part). I tried several solutions and this proved to be the easiest way to solve one of my problems. This is the code I use:

ConnectionStringSettings postavke = new ConnectionStringSettings("Kontrolor.Properties.Settings.KontrolorConnectionString", constring);
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.ConnectionStrings.ConnectionStrings.Clear();
config.ConnectionStrings.ConnectionStrings.Add(postavke);   

config.Save(ConfigurationSaveMode.Modified, true);
ConfigurationManager.RefreshSection(config.ConnectionStrings.SectionInformation.SectionName);

This code is placed inside a button_click method, and when I click that button and restart the application the changes are visible.
My question is this – is there a way to do it from another (independent) application that would enable the user to create the connection string by entering the required values into a textBox or selecting it from comboBox (he needs only to enter the IP of the server and the name of the database). By doing that, the first application would be preprepared and there would be no need to restart it to apply changes.
Is there a way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T22:51:05+00:00Added an answer on June 1, 2026 at 10:51 pm

    Since both applications are on same machine you can use simple windows messaging, register windows message in both applications and sender post message to receiver, here is the example code:

    Sender :

      public partial class FormSender : Form
      {
        [DllImport("user32")]
        private static extern int RegisterWindowMessage(string message);
    
        private static readonly int WM_REFRESH_CONFIGURATION = RegisterWindowMessage("WM_REFRESH_CONFIGURATION");
    
        [DllImport("user32")]
        private static extern bool PostMessage(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam);
    
        public FormSender()
        {
          InitializeComponent();
        }
    
        private void btnNotify_Click(object sender, EventArgs e)
        {
          NotifyOtherApp();
        }
    
        private void NotifyOtherApp()
        {
          List<Process> procs = Process.GetProcesses().ToList();
          Process receiverProc = procs.Find(pp => pp.ProcessName == "Receiver" || pp.ProcessName == "Receiver.vshost");  
          if (receiverProc != null)
            PostMessage((IntPtr)receiverProc.MainWindowHandle, WM_REFRESH_CONFIGURATION, new IntPtr(0), new IntPtr(0));
        }
      }
    

    Receiver :

     public partial class FormReceiver : Form
      {
        [DllImport("user32")]
        private static extern int RegisterWindowMessage(string message);
    
        private static readonly int WM_REFRESH_CONFIGURATION = RegisterWindowMessage("WM_REFRESH_CONFIGURATION");
    
        public FormReceiver()
        {
          InitializeComponent();
        }
    
        protected override void WndProc(ref Message m)
        {
          if (m.Msg == WM_REFRESH_CONFIGURATION)
          {
            lblMessageReceived.Text = "Refresh message recevied : " + DateTime.Now.ToString();
          }
          else
          {
            base.WndProc(ref m);
          }
        }
      }
    

    btw. note that I am checking for process name “Receiver.vshost” so that it can work when started in VS debugger

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made an application that gives the user the option to open up
I've made an application that makes full use of ajax, and what I need
I made a SmartDevice application that runs on startup and I want it to
I made a simple application that adds 1 to the count and displays the
I have made a web application that uses master page for Login & Logout
I have made a java application that stores data from a .csv file to
I have an application that is made up of the following: A central database
I inherited an Access application that I have made some changes to. When I
I have an application that needs to determine whether a user has made a
I have made a build system for my web application that's rewriting all resource

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.