Skip to content

Tricky to reference .NET Standard 2.0 components from F# Interactive #3309

Closed
@dsyme

Description

@dsyme

Referencing a .NET Standard 2.0 component from F# Interactive (fsi.exe) fails with

"netstandard.dll 2.0.0.0" is not part of the fsi.exe application or an error such as 

or

unknown(1,1): error FS3216: type 'Microsoft.EntityFrameworkCore.Design.AnnotationCodeGeneratorDependencies' not found in assembly 'Microsoft.EntityFrameworkCore.Relational, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. A possible cause may be a version incompatibility. You may need to explicitly reference the correct version of this assembly to allow all referenced components to use the correct version.

Repro steps

Provide the steps required to reproduce the problem

  1. Create a .NET Standard 2.0 component

    dotnet new classlib -o -lang F# lib2
    cd lib2
    add code file:
        module Say 
        let hello (t:System.DateTime) = printfn "the time is %A" t
    
    dotnet restore
    dotnet build
    
  2. Reference this from .NET Framework fsi.exe

Release\net40\bin\fsi.exe -r ..\misc\lib2\tplib1.dll
> Say.hello System.DateTime.Now;;

Expected behavior

Works ok and prints the current time

Actual behavior

stdin(1,1): error FS0074: The type referenced through 'System.DateTime' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard'.

Known workarounds

  1. Manually acquire the package NETStandard.Library.NETFramework

  2. Add an explicit reference to packages\NETStandard.Library.NETFramework.2.0.0-preview2-25405-01\build\net461\lib\netstandard.dll e.g.

#r @"C:\GitHub\dsyme\visualfsharp\packages\NETStandard.Library.NETFramework.2.0.0-preview2-25405-01\build\net461\lib\netstandard.dll"

Related information

master, Windows, .NET Framework 4.7 or 4.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-SetupAndDeliverySetup, packages, templates, SDK, delivery channelsBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions