Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Visual-Studio

NuPack Visual Studio Add Package References Crash and TypeLoadException

5.00/5 (1 vote)
13 Oct 2010CPOL 7.5K  
NuPack Visual Studio Add Package References Crash and TypeLoadException

This is about a couple issues I found just after deciding to give NuPack a go, and what to do if you see them.

Add Package References - Unloaded Projects

After installing, I tried the Add Package References on an existing small solution. There it crashed. This wasn’t the same scenario described at Yet Another Debugging Tale – Visual Studio Disappearing, since the classic Solution Explorer was used and at least I got the closing notification during the crash.

A quick look at the solution I had opened revealed the likely cause: a couple projects in the solution that could not be loaded. So I quickly confirmed it, removed those projects and tried again, problem gone. Bug reported.

Package Manager Console Reports TypeLoadException

When opening the console, you see the below:

System.TypeLoadException: Could not load type 
   'System.Management.Automation.Runspaces.InitialSessionState' from assembly 
   'System.Management.Automation, Version=1.0.0.0, Culture=neutral, 
    PublicKeyToken=31bf3856ad364e35'.
   at NuPackConsole.Host.PowerShell.Implementation.PowerShellHostProvider.CreateHost(IConsole console)
   at NuPackConsole.Implementation.PowerConsole.HostInfo.get_WpfConsole()
   at NuPackConsole.Implementation.
      PowerConsoleToolWindow.get_WpfConsole()System.InvalidOperationException: 
      Can't start ConsoleDispatcher. Host is null.
   at NuPackConsole.Implementation.Console.ConsoleDispatcher.Start()
   at NuPackConsole.Implementation.PowerConsoleToolWindow.MoveFocus(FrameworkElement consolePane)

The trace is a big tell here, since it mentions PowerShell right there. Searched and installed Power Shell, and I had an operational console. Specifically I used: Windows Management Framework Core package which contains PowerShell 2.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)