The Interactive Window in Visual Studio is a great utility to play around the code, language features, API’s and other .NET framework features. The Interactive Window also support features like IntelliSense, syntax highlighting and navigating through executed commands. There are several use cases for this Interactive Window, and several ways to work around it. In this quick post we will see how we can run the Interactive Window with context to a Project.
To launch the Interactive window navigate through Views > Other Windows > C# Interactive. Here you can add your code and execute it.
Read this post for details : Use C# Interactive Window for your coding experiment in Visual Studio 2015
The Interactive Windows works stands alone, if you want to call any of the current project methods, or want to run the context of the project you need to load the assembly at very first step.
Read This Post for Details : Calling current project methods from C# Interactive Window in Visual Studio 2015 ?
Then use #r to load the DLL or Executable in to it. for an example, #r “<dll path>”
With the Visual Studio 2015 Update 2, you can do the same thing in much faster and cleaner way. Right click on the project from solution explorer, and from the context menu select “Initialize Interactive with Project” option.
This will automatically load all the required assembly and the executable in the context of selected project.
Now you can use and execute other script from the context of the project inside the Interactive.
Hope this helps !