For the latest cross-platform .NET Core/Standard/6/7/... assemblies:
These assemblies are NOT supported by Visual Studio's Initialize Interactive with Project feature per open Roslyn work item here.
Also, Visual Studio versions before 2015 do not support this feature at all.
References to .NET Core assemblies (such as .dll files) can be added to the C# Interactive Window by using the #r
command in the C# Interactive window.
Here is an example usage of the #r command:
#r "C:\\path\\to\\your\DLL\\netstandard2.0\\Newtonsoft.Json.dll"
After running the above command (with the correct DLL path) in the C# Interactive window, the following line will work:
using Newtonsoft.Json;
Alternative Solution: LINQPad
For .NET Framework projects in Visual Studio between 2015 and 2022:
You can open the Interactive window by navigating to Views > Other Windows > C# Interactive,
Then just right click your project and run Initialize Interactive with Project from the context menu.
Alternative Solution: Immediate Window
Immediate Window
– Apt