How to use IronPython with App.Config?

前端 未结 6 1827
醉梦人生
醉梦人生 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:36

    I attempted to follow the answers above, but found it too complex. If you know exactly what attribute you need from your App.config file, then you can place it directly in the code. For instance, a dll I had imported needed to know the AssemblyPath attribute in my App.Config file.

    import clr
    import System.Configuration
    clr.AddReference("System.Configuration")
    from System.Configuration import ConfigurationManager
    
    ConfigurationManager.AppSettings["AssemblyPath"] = 'C:/Program Files (X86)/...
    

    This was all I needed, and the class library I was connecting to was able to see the AssemblyPath attribute it needed to run.

提交回复
热议问题