Closed phleb3 closed 9 years ago
Could you show your app.config
?
I am having the same problem on win, VS2013 An unhandled exception of type 'System.NullReferenceException' occurred in FSharp.Configuration.dll Build action : None Copy to output directory: copy if newer
open FSharp.Configuration
// Let the type provider do it's work
type Settings = AppSettings<"App.config">
[<EntryPoint>]
let main argv =
printfn "%A" Settings.TestInt
0 // return an integer exit code
Looks like github doesn't like xml in comments. http://paste.ofcode.org/p4LLKjjYXU22PyuMK2MYzm
Funny thing.. tests are ok. Must be something with setup.
Exactly the same problem here.
I'm closing it since no repro have been supplied.
This is a bug. You have unhanded exception in AppSettingsTypeProvider (in my case) in
An unhandled exception of type 'System.NullReferenceException' occurred in FSharp.Configuration.dll
let getConfigValue key
...
settings.[key].Value
Because var settings length is zero and you are trying to access key that doesn't exist. There should be either check if element exists or exception handling.
And it happens because sometimes (I can reproduce it with 100%) app.config content is not moved to ConsoleApplication1.exe.config file. It looks like it doesn't recognise small changes like formatting and depends on operation order (add code, add config / add config, add code). So removing something big from file, recompiling it and then redo change (ctrl+z) solves the problem for me.
I used nuget to install fsharp.configuration, and followed the instructions. Code:
type Settings = AppSettings<"app.config">
then
let test1 = Settings.TestKey < this returns a null exception