Why am I getting this exception when using CommonOpenFileDialog in a Console Application?

I'm trying to use CommonOpenFileDialog's folder picker, as described in this answer. The problem is that even with a very stripped down example project I get an exception when trying to use CommonOpenFileDialog's ShowDialog() function.

The Code

using Microsoft.WindowsAPICodePack.Dialogs; namespace DialogTest < class Program < public static void Main(string[] args) < CommonOpenFileDialog dialog = new CommonOpenFileDialog(); dialog.InitialDirectory = "C:\\Users"; dialog.IsFolderPicker = true; CommonFileDialogResult result = dialog.ShowDialog(); if (result == CommonFileDialogResult.Ok) < //Do Stuff >> > > 

The Exception

This code produces the following exception at dialog.ShowDialog(); :

System.Runtime.InteropServices.COMException was unhandled ErrorCode=-2147023116 HResult=-2147023116 Message=A null reference pointer was passed to the stub. (Exception from HRESULT: 0x800706F4) Source=Microsoft.WindowsAPICodePack.Shell StackTrace: at Microsoft.WindowsAPICodePack.Dialogs.IFileDialog.SetFileName(String pszName) at Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialog.ApplyNativeSettings(IFileDialog dialog) in c:\projects\Windows API Code Pack 1.1\source\WindowsAPICodePack-NuGet\Shell\CommonFileDialogs\CommonFileDialog.cs:line 768 at Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialog.ShowDialog() in c:\projects\Windows API Code Pack 1.1\source\WindowsAPICodePack-NuGet\Shell\CommonFileDialogs\CommonFileDialog.cs:line 609 at DialogTest.Program.Main(String[] args) in c:\users\obscerno\documents\visual studio 2015\Projects\ConsoleApplication2\ConsoleApplication2\Program.cs:line 13 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: 

Some Other Relevant Details

  1. I'm using Visual Studio 2015.
  2. One strange thing about this error is that this code was working a year ago. I just re-opened the project planning to make some small changes and it was no longer functioning.
  3. On creating a new test project, on the first run I'm prompted by Visual Studio to locate a file called CommonFileDialog.cs . The initial directory that it checks for the file at is "c:\projects\Windows API Code Pack 1.1\source\WindowsAPICodePack-NuGet\Shell\CommonFileDialogs\CommonFileDialog.cs" which does not exist on my computer. If I select "cancel" the prompt does not return during future debugs. I suspect this missing file is the source of the problem, but don't know what to do with this information.

What I've Tried

  1. Searching the exception didn't turn up much of anything, aside from this amusing but irrelevant question.
  2. Installing the same nuget packages from multiple sources didn't give me any different results. There are quite a few copies of the packages because for a while Microsoft made them unavailable.
  3. I tried searching my computer for the file "CommonFileDialog.cs" but it's nowhere to be found.