Is there a configuration type file for the Visual Studio Add-in?

When creating a Visual Studio add-in, how can you use app.config for the add-in. If I add it to the project and deploy it, then when the add-in is launched, and I programmatically try to access it through ConfigurationManager.AppSettings without collecting the configuration file for the add-in.
Am I doing something wrong or is there another way to access file-based configuration settings for the add-in?

+5
source share
1 answer

ConfigurationManager.AppSettings collects a configuration file for the AppDomain you download. This configuration file is usually the one associated with the entry point executable. In your case, you do not control the entry point executable file and do not start the AppDomain application, so you cannot use ConfigurationManager.AppSettings.

Basically you ask the question: "How can I create a configuration file associated with a DLL?" ( C # Dll configuration file ). You need to do two things:

  • Add the application configuration item to your project and make sure that you deploy it to the same folder as your DLL.
  • Access the configuration file from your DLL using the following code:

     string pluginAssemblyPath = Assembly.GetExecutingAssembly().Location;
     Configuration configuration = ConfigurationManager.OpenExeConfiguration(pluginAssemblyPath);
     string someValue = configuration.AppSettings.Settings["SomeKey"].Value;
    

DLL , . , VS . , , DLL, .

+7

All Articles