1

I am running .NET console application from shared network folder on several Windows 2008 machines and would like to have separated app.config file for every Windows 2008 machine on which console is run. What is the best method to do that?

1 Answer 1

1

You have some options, which depend upon whether you can change and recompile the console application or not:

  1. Put copies of your executable and dependent libraries in separate subdirectories and provide custom app.config for each. Like a share/subdirectory per client machine. This could, of course, turn into a maintenance nightmare or space hogging experience. For simple solutions/needs it might still be feasible though.
  2. As a variation of (1) put copies of the same console application binary in the same directory, with different names. Put individual versions of the app.config, named like the copies of the executable in the same directory. Again, this has the same, if not more, issues than (1), but could work, depending on your precise requirements.
  3. Restart your executable itself from a new AppDomain. This allows you to specify a custom path/filename for the app.config for the new application domain. Shameless plug: https://stackoverflow.com/a/3633158/21567. Note that this approach is not limited to executing your own assembly inside the new application domain. You could also write a managed stub application that just does an ExecuteAssembly on the console application you really want to run (which may not be able to change), providing it a custom app.config.
  4. Write a native stub process that hosts the CLR itself. This will also allow you to specifiy the path/name of the app.config file to use.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.