You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 ====//letenv= 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
The text was updated successfully, but these errors were encountered:
The desktop build of fsi doesn't preload System.Configuration.dll, and never has.
To make this work on desktop FSI, add this at the top of the script:
#r @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Configuration.dll"
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>fsi
Microsoft (R) F# Interactive version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.
For help type #help;;
> #r @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Configuration.dll"
- #r "nuget: System.Configuration.ConfigurationManager"
- open System.Configuration
- System.Configuration.ConfigurationManager.AppSettings.Item "Environment" <- "LOCAL";;
--> Referenced 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Configuration.dll' (file may be locked by F# Interactive process)
[Loading C:\Users\codec\AppData\Local\Temp\nuget\2408--83596b72-a4c3-4bc9-87f9-5c2a043adedd\Project.fsproj.fsx]
namespace FSI_0002.Project
val it : unit = ()
>
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
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
The text was updated successfully, but these errors were encountered: