[C#]dllinheritance iconfigurationsectionhandlercan be used to host the. exe. config

Source: Internet
Author: User

Generally, only the Application can use the custom IConfigurationSectionHandler interface class to read the configuration in app. config.

Only two steps are required:

Step 1: Define a class in your application:

Public class ActionConfigurationSectionHandler: IConfigurationSectionHandler, and
Overload public object Create (object parent,
??? Object configContext,
??? System. Xml. XmlNode section) method.

Then, in app. config, like log4net:

??

??? Type = "log4net. Config. Log4NetConfigurationSectionHandler, log4net"/>
?

Note: enter the name and namespace of your class in the type attribute.

However, in general, only the exe and Web pages can use these default configuration files. For a custom DLL, you can only write a class for processing configuration files to specify which configuration file to use.

Otherwise, the DLL will reuse the configuration file of the EXE that calls it.

ConfigurationSettings. GetConfig ("ActionServlet/ActionsMap ")

The configuration file someapp.exe. config of the exeis located on the attachment.

?

I have a dlland actionconfigurationsectionhandlerclass, and define it in someapp.exe. config.

???? Type = "ActiveServlet. ActionConfigurationSectionHandler, ActiveServlet"/>

Hope to use ConfigurationSettings. GetConfig ("ActionsMap ")

?

Trackback: http://tb.blog.csdn.net/TrackBack.aspx? PostId = 58895

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.