In Visual Studio 16.8.0 error FS0039 is encountered when trying to access System.Configuration.ConfigurationManager after bringing in the NuGet package via #r "nuget: System.Configuration.ConfigurationManager".
Repro steps
- Paste the following code in to an F# Scrip file in Visual Studio.
//
// ==== Bring in Dependency ====
//
#r "nuget: System.Configuration.ConfigurationManager"
//
// ==== Set Environment ====
//
System.Configuration.ConfigurationManager.AppSettings.Item "Environment" <- "LOCAL"
//
// ==== Get Environment ====
//
let env = System.Configuration.ConfigurationManager.AppSettings.Item "Environment"
match env with
| "LOCAL" -> printf $"In LOCAL environment"
| _ -> printf $"Environment unknown"
- The following error appears in Visual Studio editor

- Try to execute in F# interactive, the following error is shown

- If you run the script via command line, everything works

Expected behavior
Expected to be able to execute above code in F# Interactive Window
Actual behavior
Cannot execute above code in F# Interactive Window
Known workarounds
I can just execute via command line, but that's no fun.
Related information
- Windows 10 Version 1909
- dotnet SDK 5.1.100
- Visual Studio 16.8.0