dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.99k stars 4.03k forks source link

C# Interactive does not use .NET Core 8 SDK in Visual Studio 2022 #71434

Open vsfeedback opened 9 months ago

vsfeedback commented 9 months ago

This issue has been moved from a ticket on Developer Community.


[severity:It's more difficult to complete my work] In Visual Studio 2022, I opened the "C# interactive" tool, used "#r" to import the class library I had compiled from Solution Explorer, and attempted to run a public static function from my assembly. I received the error:

(1,33): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

I referred to some previous issues, and made sure that I ran the command "#reset core" and still received the same error.

As the comments in another issue ([Make-C-Interactive-use-Net-Core/746242]) point out, this is a bug in how the version of a tool is packaged with visual studio. Perhaps the version of this component needs to be updated for the installation.

This is with visual studio 17.8.3 "dotnet --version" reports 8.0.100

Desired Behavior: As a developer working with the LTS Release of the .NET 8 SDK in visual studio 2022, I would like to be able to compile my class library targeting .NET 8, reference the output in "C# Interactive" by loading my assembly with the existing "#r" command, and execute methods from my assembly (as a default experience).

Any errors reflected in C# Interactive should be reflective of errors in the code.


Original Comments

Feedback Bot on 12/10/2023, 08:33 PM:

(private comment, text removed)


Original Solutions

(no solutions)

JiriZidek commented 7 months ago
Microsoft (R) Visual C# Interactive Compiler version 4.9.0-3.24121.1 ()
Loading context from 'CSharpInteractive.rsp'.
Type "#help" for more information.
> Environment.Version
[6.0.28]

But we use .net8 now so what ? And "Initialize Interactive with Project" does not show even for .net standard 2.0 lib projects...