Skip to content

Error accessing System.Configuration.ConfigurationManager in F# Script and F# Interactive on Visual Studio 16.8.0 #10550

@alexchro93

Description

@alexchro93

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

  1. 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"
  1. The following error appears in Visual Studio editor

image

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

image

  1. If you run the script via command line, everything works

image

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-FSIArea-VS-FSIVS window and commands for F# Interactive

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions