New C# REPL and scripting capabilities


Along with a number of other welcome additions to Visual Studio, Visual Studio 2015 Update 1 brings back and old friend. the C# Interactive Window.  The C# Interactive Window is what’s known as a “Read-Eval-Print-Loop” (REPL).  Interactive Windows are great when you just need to test a simple block of code, and don’t want to create an entire sample project, or code file. 

Opening the C# Interactive Window

Once you have Visual Studio 2015 with Update 1 running, From the menu bar, select “View” | “Other Windows” | “C# Interactive


Once the “C# Interactive” window appears, you can issue a “#help” command to get basic help on the commands available:


For a full set of documentation, you can check out Interactive Window Documentation on GitHub. You should also check out Kasey Uhlenhuth’s “Introducing the Visual Studio ‘C# REPL’” video from the “Connect(); //2015” event.  The documentation and Kasey’s video gives a pretty good introduction to the functionality so I won’t try to repeat that here, however, there are a few extra things I’ve found that I thought I’d share with you.

Give it a Try

If you have the Interactive Window open, you can try just entering a simple expression like “Hello, “ + “World!” and pressing ENTER.  You should see the result “Hello, World!” printed out for you.


Let’s try something with variables (you can use the #cls or #clear commands to clear the interactive window before moving on if you like a clean slate):


If you want to reset the state of the interactive window, including any variable or method declarations, you can use the #reset command.  The reset command clears the state, and reloads the “CSharInteractive.rsp” file to provide a default set of references and namespace imports (“using” directives). For example, here you can see that once I issue the #reset, the hello and world variables are now undefined.


To Semi-Colon or Not To Semi-Colon

When you type an expression (like “Hello, “ + “World!” ) into the window, you never use a semi-colon at the end, because it is an expression, not a statement.  The interactive window will always evaluate expressions, and output the result. 

When working with statements however, they MAY return a result (like in a method that returns a string).  For example, here I will create a method, called Concat that returns a string back to the caller.


Now, I’m going to call the method like an expression, WITHOUT a semi-colon.  Notice that the return value is displayed:


However, if I call it like a statement by adding a semi-colon.  The statement is executed, but the return value isn’t displayed. 


Command Line REPL

Lastly, I’ll mention that there is a command line version of the REPL functionality.  It doesn’t support all of the same commands as the interactive window, notably #clear, #cls and #reset are missing.  For the #clear and #cls commands, you can just use the command prompt’s cls command.  For the #reset, just stop the REPL and restart it. 

You need the Visual Studio tools to be in the path, the easiest way is to just use the “Developer Command Prompt” shortcut installed with Visual Studio:


From there, you can use the “csi.exe” command line REPL utility.  Calling “csi” with a “/?” parameter shows it’s optional parameters:


Here is the command prompt version of our Concat method and calls from before:


You can exit the REPL by typing Ctrl-C.

CSX Scripts

Lastly, you can save your C# scripts into a text file with a .csx extension.  Actually, the extension isn’t really important as long as you reference the full name when call it.  For example, I’ve saved a version of our Concat method declaration and call from above in a text file:


With your CSX scripts, you can’t have loose expressions (like “Hello, “ + “World!”).   All code needs to be wrapped up in methods or be statements.  Also, output is not automatically displayed.  If you want to see something, output it yourself using Console.WriteLine(), etc.


Wrap Up

It’s great to have the C# interactive window back.  I think there are a lot of use cases this will help solve and as a person who does demos a lot I think it will be a handy way to demo small concepts.  Check out the documentation, give it a try, and let me know what you think !

View your Application Insights data in Visual Studio

If you haven’t tried Microsoft Azure Application Insights before, it is a powerful tool for gaining insights in to how your web apps or mobile apps are being used, how they are performing, and what issues they may have.  You can even setup alerts in Application Insights to keep you informed when things happen that you care about.

Until now, you would primarily view the Application Insights data for your application using the Azure Portal (


Now with the Visual Studio 2015 Update 1 release though, you can now view Application Insights Data from right within Visual Studio 2015. To do so, from the Visual Studio 2015 menu bar, select “View” | “Other Windows” | “Application Insights Search


Then, when prompted select the Application Insights Resource you want to use:


Finally, you can use the search an filter criteria to zero in on exactly the Application Insights data you want to see


This new features makes it even easier to gain meaningful insight into your applications.  Give it a try and let me know what you think!

New Azure Client OS VM Images for Windows 8.1 and Windows 7

I love the awesome surprises I get in the Azure Management Portal on a regular basis!  Today’s (05/12/2014) was an awesome set of new base images for MSDN subscribers:


Yep, you see correctly, Windows 8.1 Enterprise and Windows 7 Enterprise images, including some with Visual Studio 2013 Update 2 already installed! w00t!

I also noticed that a number of new extensions are available as well!  Including “Custom Script” and numerous “Security Extensions” with support for Microsoft Antimalware, as well as Symantec Endpoint Protection and Trend Micro Deep Security Agent.  Time to go learn more! 


Oh, and look at these tantalizing new preview features! Azure RemoteApp and Windows Azure Files, an SMB File Share service!


SQL Server Data Tools for SQL Server 2014 fixes SQL publish.xml “Unable to connect to target server” Errors

If you have a SQL Database project in Visual Studio 2013, with a *.publish.xml file that you are trying to use to deploy the database to a SQL Server 2014 instance, you may be receiving an error stating that the data tools are “Unable to connect to target server”:


If that is the case, then you likely haven’t installed the updated SQL Server Data tools For SQL Server 2014

You can learn more about the SQL Server Data Tools (SSDT) here:

Anyhow, The fix is easy! 

  1. From the Visual Studio 2013 menu bar, select “TOOLS” | “Extensions and Updates…”
  2. In the “Extensions and Updates” window, along the left, select “Updates” | “Product Updates” and then select the “Microsoft SQL Server 2014 Update for database tooling” update and click the “Update” button.


  3. Follow the prompts to complete the install.  You may want to close Visual Studio 2013 while the tools update installs, and re-open Visual Studio and your project when the installation completes.

Once you have the updated tools install, you should be back in business, and your publish process should succeed!


Cleaning out Visual Studio’s Cluttered Closet

I do a lot of tweaking in Visual Studio’s options.  A tweak here to test so esoteric feature of .NET, a tweak there based on some input from some guru, a tweak during a demo to show some debugging option, a tweak, a tweak, a tweak.

So lately I’ve had problems during my debugging demos.  The debugger just wasn’t behaving the way I expected it.  More than once during some presentation, I’ve had to say “well, it not supposed to do that, its supposed to …”, and it has been getting a little embarrassing. 

There are large number of debug options available to us (which is generally a good thing), but trying to figure out what tweak needs to be un-tweaked is near impossible because of it. Rather than go switch by switch to determine the cause, I thought it would be better to just reset them all to their defaults.  Unfortunately, there isn’t a “Reset All” button in the debugging options of Visual Studio.  So how do you do it?

You could do it from the command prompt:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe /ResetSettings

However if is even easier, and more flexible if done from within Visual Studio.  From the Visual Studio menu bar select “Tools|Import and Export Settings…”.  Use the wizard to first save your current settings (in case you forgot some special setting you really wanted, this will let you recover your settings to find out what it was), then import a previously saved set of settings, or import a set of default settings provided with Visual Studio.  Finally, you can select the specific options you want to import, so you don’t have to reset everything if you don’t want to:

 click the image below to see the wizard pages…
 Reset Visual Studio Settings Landscape