How to use IronPython with App.Config?

前端 未结 6 1848
醉梦人生
醉梦人生 2021-02-05 07:13

I have a class library that is usually called from a .net console or web application. It integrates with various components, and relies on an app.config or web.config.

I

6条回答
  •  情话喂你
    2021-02-05 07:41

    You can look at the System.Configuration.ConfigurationManager class. More specifically, OpenMappedExeConfiguration method will allow you to load any .config file of your choice. This will give you a Configuration object which exposes the standard AppSettins, ConnectionStrings, SectionGroups and Sections properties.

    This approach requires you to pass the name of the config file to your script as a command line argument or to have a code logic to choose the .config file at run-time.

    I know no Python, so I would refrain from attempts to post sample code. :-)

提交回复
热议问题