This post was originaly published to Stuff the Box on 22 Feb 2014

This is a post that I originally wrote on the Microsoft Development Team’s Brain Dump blog at work the other day, and thought I’d share it with my non-work viewers too


So, it turns out that you can test WinFroms (and WPF) UI controls from within LINQPad!1

First save and build your project so that you have an/the assembly (*.exe, *.dll). Once you have a build, fire up LINQPad and right click on the query tab and select Advanced Properties. On the Additional References tab select Add and then Browse. Find the assembly that you did a build of and click OK; add any other necessary assemblies, i.e. System.PresentationFramework.dll, System.Windows.Forms.dll, System.Xaml.dll, etc. Once you have all of your assemblies added, switch to the Additional Namespace Imports tab and click Pick from assemblies and select the appropriate namespaces from all the assemblies that you need; this is what will give you IntelliSense.

Once you have done the above, you can close the Advanced Properties window and change the Language to C# Program (or VB Program … if you like pain ;P). Now you can create a new instance2 of your WinForms/WPF window and test3 out the UI without executing your app! You could even use LINQPad as a way of doing some Unit Tests or some such if you were really inclined …

Happy testing and debugging!


  1. I stumbled across this post by Matthew MacSuga which describes this awesome feature; I have however documented my method of testing WinForms UI and confirming WPF support 

  2. Beware class/constructor access; if you have your class, constructor/s or other methods set to internal instead of public, you will not be able to create a new instance of your UI :( 

  3. Make sure that you set .ShowInTaskbar = true to ensure that you have a hook to kill the window if something goes wrong; especially if you are using .ShowDialog() to display it