Omnisharp-roslyn: In csharp script using .netstandard library: The type 'List<>' is defined in an assembly that is not referenced.

Created on 26 Oct 2017  路  3Comments  路  Source: OmniSharp/omnisharp-roslyn

I'm using a script referencing a assembly compiled with .net standard 2. When i use a property of type List'1, I'm getting the error in vscode:

The type 'List<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. [testValidation.csx]

Is possible to reference a assembly compiled with .net standard 2 from a csx file, and that the intellisense works properly in vscode?

csx

Most helpful comment

@gabomgp by default OmniSharp assumes net46 mode for resolving script dependencies. You can add #! "netcoreapp2.0" directive at the top of your script to force the assembly resolution to assume .NET Core 2.0 mode.

The alternative is to manually reference netstandard.dll (which is only used for type forwarding) i.e. from C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.0. At the end of the day, it also depends how you will run your script (with which script runner), and whether it's able to understand NET Standard 2.0.

All 3 comments

@gabomgp Can you share your omnisharp log?

@gabomgp by default OmniSharp assumes net46 mode for resolving script dependencies. You can add #! "netcoreapp2.0" directive at the top of your script to force the assembly resolution to assume .NET Core 2.0 mode.

The alternative is to manually reference netstandard.dll (which is only used for type forwarding) i.e. from C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.0. At the end of the day, it also depends how you will run your script (with which script runner), and whether it's able to understand NET Standard 2.0.

@filipw Thanks you very much. You resolved my question.

Was this page helpful?
0 / 5 - 0 ratings