App.config and F# Interactive not working

前端 未结 6 1312
陌清茗
陌清茗 2020-12-17 10:53

As I\'m polishing my little pet project, I\'m trying to store all the constant strings in my app.config file (Keys, XpathExpressions etc). When I run the compiled exe this w

6条回答
  •  借酒劲吻你
    2020-12-17 11:34

    While FSI dynamically generates code for your input, using the fsi.exe.config will work just fine.

    I created this file:

    
        
            
        
    
    

    And saved it as "fsi.exe.config" (program files\fsharp-version\bin).

    Then started FSI:

    > #r "System.configuration";;
    --> Referenced 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.configuration.dll'
    
    > System.Configuration.ConfigurationManager.AppSettings.["test"];;
    val it : string = "bar"
    

    It also worked from Visual Studio. (But note that you'll need to reset the session to pickup changes.)

提交回复
热议问题