Posts Under Tag: Visual Studio

Can’t Install NuGet Package Because of “Failed to initialize the PowerShell host”

I was attempting to install the Newtonsoft.Json v. 6.0.4 NuGet Package in a project and received an error message beginning with the text, “Failed to initialize the PowerShell host…”.  Interesting.  I know the PowerShell execution policy can be restrictive by default so I opened Visual Studio 2013’s Package Manager Console and entered the command:


It came back as RemoteSigned.  RemoteSigned **should** be fine for this package and for any package in the public NuGet feed.  I thought perhaps something was overlooked in the signing of the published package so I changed the execution policy in my Package Manager Console (note: Visual Studio has to be run as Administrator to do this).

Set-ExecutionPolicy Unrestricted

An Unrestricted policy doesn’t care if the package is signed or not; it’s a run-at-your-own-risk setting.  But still, I received the same error!  I ran Get-ExecutionPolicy and noticed it was still set to RemoteSigned.  So it was time to do some Goggling and I ran across a great StackOverflow answer and accompanying comment for this same problem.  The poster to the answer stated,

Be aware that changes will be applied according to the bit version of the PowerShell console, so 32bit or 64 bit.

I use a 64 bit environment so this had to be the problem!  A commenter to that StackOverflow answer posted how to actually do this in the Package Manager Console:

start-job { Set-ExecutionPolicy Unrestricted } -RunAs32 | wait-job | Receive-Job

Once I ran that, Get-ExecutionPolicy returned Unrestricted.  I made another attempt to install the NuGet package and it worked!

Tags: Filled Under: Programming Posted on: September 26, 2014

Does your Visual Studio 2013 hang when editing VB.NET classes?

If so, the answer to this problem for me was uninstalling the NUnit Test Adapter VS2013 extension.  Although useful for calculating code coverage when using NUnit, it totally froze up VS2013 on any keystroke within the class file.  Hopefully they’ll fix this in a future build!

Happy New Year!

Tags: Filled Under: Programming Posted on: December 31, 2013