When creating a Visual Studio Add-In, how can you utilise an app.config for the add-in. If I add one to the project and deploy it then when the Add-In runs and I programmatically try to access it via the ConfigurationManager.AppSettings its not picking up the config file for the add-in.
Am I doing something wrong or is there another means to access file based configuration settings for an add-in?
Settings. settings is located in the My Project folder for Visual Basic projects and in the Properties folder for Visual C# projects. The Project Designer then searches for other settings files in the project's root folder.
Configuration files are normally saved in the Settings folder inside the My Documents\Source Insight folder.
A CONF file is a configuration or "config" file used on Unix and Linux based systems. It stores settings used to configure system processes and applications. CONF files are similar to . CFG files found on Windows and Macintosh systems.
ConfigurationManager.AppSettings picks up the configuration file for the AppDomain you are loaded into. That config file is typically the one associated with the entry point executable. In your case, you don't control the entry point executable nor the AppDomain you run in so you can't use ConfigurationManager.AppSettings.
You question basically boils down to "How can I have a config file associated with a DLL?" (C# Dll config file). You need to do two things:
Access the config file from your DLL using code like this:
string pluginAssemblyPath = Assembly.GetExecutingAssembly().Location;
Configuration configuration = ConfigurationManager.OpenExeConfiguration(pluginAssemblyPath);
string someValue = configuration.AppSettings.Settings["SomeKey"].Value;
That will definitely work for regular DLLs that are not loaded using shadow copy. I'm not sure how VS loads its plugins. If you run into problems, let me know and I can post a work around for DLLs that get loaded via shadow copy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With