I have a C# cmdlet(1) that uses "ConfigurationManager.AppSettings" to get database connection strings necessary for some stored procedures used in the cmdlet(1). If another application instantiates an instance of the cmdlet(1) class object, then calls a method on the class that use a stored procedure an error is thrown because the other application/project(2)'s app.config does not have the same app.config settings.

I think application(2)'s config should be updated with the same settings needed basically copying the connection string from the cmdlet(1).

My question is whether the approach is typical and best practice or should the cmdlet(1) be responsible for all calls that depend on its own app.config settings.

  • 1
    App.Config is not designed to pass dynamically-changed settings from one application to another in the manner you described. You'll have to figure out another way. Aug 17, 2016 at 22:01
  • @RobertHarvey I updated my question as it was not clear I believe, the settings would be the same, not changed. Project(dll) 2 would just add a new key value pair to its config, unless I am misunderstanding.
    – Rayshawn
    Aug 17, 2016 at 22:19
  • I think the question you should really be asking is whether or not it's a good idea to be passing database credentials over the wire. Aug 17, 2016 at 22:23
  • Ah, thanks @RobertHarvey I think that answers my question, no not a good idea.
    – Rayshawn
    Aug 17, 2016 at 22:26


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.