Can a class library have an App.config file?

后端 未结 7 1140
别跟我提以往
别跟我提以往 2020-11-27 04:04

Here is what my solution is looking like at the moment:

\"enter

In the Tutomen

7条回答
  •  醉话见心
    2020-11-27 04:51

    No, class libraries can hold setting files, but their values will be defined in the application configuration (web.config, app.config...).

    That's because of configuration settings overriding feature.

    You'll need to declare the assemblies' configuration sections in the app.config or web.config of your application (WPF, SL, ASP.NET...) and define a value for a particular number of settings defined in the proper assembly settings.

    EDIT: Add a setting file to your project and add a setting with application scope, and your assembly would have something like this:

    
    
        
            
                
    a value

    Now you'd need to go to your application, and you need to copy-paste the section group, and section declarations, and the definition of the values for the settings. That's all.

提交回复
热议问题