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
Setting APP_CONFIG_FILE does the job "if it's early enough". It doesn't appear to be able to do it early enough in the .fsx file. So it needs a reset, as per this post: Change default app.config at runtime
In F#, it looks like this:
open System
open System.Configuration
open System.IO
open System.Reflection
let appConfigPath = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "App.config")
AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", appConfigPath)
typeof
.GetField("s_initState", BindingFlags.NonPublic ||| BindingFlags.Static).SetValue(null, 0)
typeof
.GetField("s_configSystem", BindingFlags.NonPublic ||| BindingFlags.Static).SetValue(null, null)
(typeof.Assembly.GetTypes()
|> Array.find (fun x -> x.FullName = "System.Configuration.ClientConfigPaths"))
.GetField("s_current", BindingFlags.NonPublic ||| BindingFlags.Static).SetValue(null, null);;