5

Day 1:

System: Windows 10
Microsoft Visual Studio Community 2017 
Version 15.5.5
VisualStudio.15.Release/15.5.5+27130.2026

I have a website project that is making use of the WindowsAzure.Storage NuGet package.

From within Visual Studio, I do the following:

Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution ...

The system displays 2 updates are available:

Newtonsoft.Json v10.0.3 (currently installed v9.0.1)
WindowsAzure.Storage v9.0 (currently installed v8.7)

I select check the "Select all packages" checkbox and click the "Update" button.

FAIL (Never had this happen before) !!

Below is the output captured from Visual Studio:

Retrieving package 'WindowsAzure.Storage 9.0.0' from 'nuget.org'.
...
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3007) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3014) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3021) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3028) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3035) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The term 'Get-ExecutionPolicy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Install failed. Rolling back...

Error List Window shows:

Failed to initialize the PowerShell host. If your PowerShell execution policy setting is set to AllSigned, open the Package Manager Console to initialize the host first.

Powershell output from: Get-ExecutionPolicy -List output:

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser    Unrestricted
 LocalMachine    Unrestricted

Is there a problem with the NuGet package itself or my system?

I have never had this issue before and after searching for a solution (none found so far) -- I am at the mercy of the NuGet / Visual Studio gods!

Thanks in advance.

======

Day 2: 8:00 am ...

Trying again... Lets see if we can get the Package Manager Console working...

Start Visual Studio (Community 2017)

TOOLS -> NuGet Package Manager -> Package Manager Console

Which results in the following being displayed:

The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3007) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3014) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3021) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3028) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3035) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The term 'Get-ExecutionPolicy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Back to the drawing board! Will continue looking for a solution...

So, let's try Visual Studio Installer...

Launch Visual Studio Installer
Select "More" -> "Repair"

Which results in:

The dependent package cannot be found: Component.PowerShellTools.VS2017,version=3.0.585

I click on "View Log", which displays:

[1cb4:000a][2018-02-17T08:27:06] Error 0x80131500: The dependent package cannot be found: Component.PowerShellTools.VS2017,version=3.0.585
   at Microsoft.VisualStudio.Setup.Dependencies.DependencyManager.FindDependentPackages(Dependency dependency, DependencyComparer comparer, Dictionary`2 packageIndex)
   at Microsoft.VisualStudio.Setup.Dependencies.DependencyManager.BuildGraphRecursive(IPackage graphRoot, DependencyNode node, DependencyComparer comparer, Dictionary`2 packageIndex, Dictionary`2 nodeIndex, Boolean splitNodes)
   at Microsoft.VisualStudio.Setup.Dependencies.DependencyManager.BuildGraphCore(IPackage root, IEnumerable`1 packages, DependencyComparer comparer, Dictionary`2 packageIndex, Dictionary`2 nodeIndex, Boolean splitNodes, DependencyCollection deprecated)
   at Microsoft.VisualStudio.Setup.Dependencies.DependencyManager.BuildGraph(IPackage root, IEnumerable`1 packages, Boolean isUpdate, IDependencyComparisonSeed seed, DependencyCollection deprecated)
   at Microsoft.VisualStudio.Setup.Engine.GetDependencyGraph(Product product)
   at Microsoft.VisualStudio.Setup.Engine.PreChecks(String installationPath, Boolean isLayoutSet, Product product, ExecuteAction bootstrapperAction, ITelemetryOperation operation, IQuery query)
   at Microsoft.VisualStudio.Setup.Engine.Repair(CancellationToken token)

Ok - so somehow, my system has lost a dependent package (Component.PowerShellTools.VS2017) -- will try modify to see if I can add the package...

======

Day 2 - 10:15 am (still at it) - current state -- at wits end...

Microsoft Visual Studio Community 2017 
Version 15.5.6
VisualStudio.15.Release/15.5.6+27130.2027
Microsoft .NET Framework
Version 4.7.02556

I do the following:

TOOLS -> NuGet Package Manager -> Package Manager Console

Which results in the following being displayed:

enter image description here

If anyone (Microsoft) has a solution -- I would REALLY appreciate it !

======

Day 2: 3:09 pm ...

In one final (desperate) attempt, I Launched Visual Studio Installer

Click on "More" -> "Repair" ....

After a couple of hours Visual Studio was (re)installed:

Microsoft Visual Studio Community 2017 
Version 15.5.6
VisualStudio.15.Release/15.5.6+27130.2027
Microsoft .NET Framework
Version 4.7.02556

I then do the following (after lighting 12 candles and chanting "Bill-Bill-Bill")...

TOOLS -> NuGet Package Manager -> NuGet Manager Console

Result:

The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3007) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3014) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3021) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3028) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3035) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The term 'Get-ExecutionPolicy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

I am doomed -- I cannot use Visual Studio until this is fixed.

======

Day 3 - 7:49 am

I see my issue has been Triaged by MSFT at:

https://developercommunity.visualstudio.com/content/problem/199976/visual-studio-failed-to-initialize-the-powershell.html

Have also tried the "solutions" from these resources:

https://developercommunity.visualstudio.com/content/problem/154563/failed-to-initialize-the-powershell-host.html

https://learn.microsoft.com/en-us/nuget/release-notes/known-issues#opening-package-manager-console-fails-with-objectsecurity-exception

Unfortunately, none of the above have helped to correct this issue.

Most posts indicate a complete re-install of VS may be needed -- good grief!!

Hoping a solution will be found that DOES NOT REQUIRE A COMPLETE RE-INSTALL!

======

Day 3 - 1:54 pm

Gave up ...

  1. UNINSTALLED Visual Studio. Shutdown (powered down system)
  2. Startup (powered up system)
  3. Downloaded Visual Studio installer from https://www.visualstudio.com/downloads/
  4. Ran Disk Clean app as per installer instructions.
  5. Shutdown (powered down system)
  6. Startup (powered up system)
  7. Ran Visual Studio 2017 Community Installer - success.
  8. Start Visual Studio
  9. TOOLS -> NuGet Package Manager -> Package Manager Console

Result:

The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3007) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3014) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3021) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3028) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3035) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The term 'Get-ExecutionPolicy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

So - not even a fresh installation of Visual Studio Community is solving this problem !!!!

======

Day 4 - 9:11 am

Late last night I opened a new issue at GitHub re PowerShell, see:

https://github.com/PowerShell/PowerShell/issues/6189

This morning, found a reply and took the suggestion of lzybkr and disabled Powershell V2; I posted the commands for disabling V2 on the GitHub post above.

The good news - I was able to update packages via NuGet again!

The bad news - If I start Visual Studio and then do:

TOOLS -> NuGet Package Manager -> Package Manager Console

The console window opens, but simply hangs with the following message:

Initializing Powershell host...

I STILL have NO idea WHAT is causing this behavior within Visual Studio; but after 4 days, I am just considering myself lucky that I can (once again) update NuGet packages and get back to work.

Although my "issue" of updating NuGet packages has (for the most part) been resolved, I still do not see this as a solution as the root cause of why Visual Studio / NuGet Package Manager Console cannot initialize the PowerShell host has NOT been resolved.

Should anyone find the root cause, please post your solution.

3
  • My sympathies. I went through a similar ordeal last week - a multi-party versioning catch-22 involving VS, Azure, and NuGet. I read through your question but it doesn't appear to be the same thing. Frankly I was so burnt out by the end of it, I'm not sure how much help I would have been anyway. Commented Feb 17, 2018 at 3:07
  • Good lord! Thanks for the comment -- looks like I am heading on a trip to hell! BTW - I just updated Vistual studio to 15.5.6 -- same result. ugh! Commented Feb 17, 2018 at 3:24
  • I did the same upgrade myself midway through my ordeal. It made things more complicated in my case because, well you know the saying about changing horses midstream. Hopefully your issue doesn't have as many moving parts. Commented Feb 17, 2018 at 3:43

2 Answers 2

2

The following finally solved the problem described above:

https://developercommunity.visualstudio.com/content/problem/199976/visual-studio-failed-to-initialize-the-powershell.html

Sign up to request clarification or add additional context in comments.

4 Comments

This saved me. I tried numerous solutions but none works. Finally this one works. I use Visual Studio Professional 15.6.4 (the latest as of this post)
This solution somehow doesn't work when this happen again on my machine. I even reintalled vs 2017. I later succeeded with this solution: developercommunity.visualstudio.com/content/problem/35803/… this is similar, except that it is done for the current user and not for admin, and that it includes more items.
I'm experiencing the same issue on Visual Studio Professional 2019 16.4.0. From the linked MS Developer Community post it is not clear in which folder under AppData\Local\Microsoft\VisualStudio` the devenv.exe.config` file should be edited. I tried the only folder that had a name starting with 16 (specifically 16.0_0c833e6b) but it did not help
I tried this for VS2019 but it didn't work.
1

We have finally identified the root cause of the issue, and will be fixing in 15.8 release of Visual Studio.

For now, the possible workarounds for this are:

1) Install .NET 2.0 on your machine, which will install the System.Management.Automation Version=1.0.0

2) Use the binding redirect as suggested by some of the members of the community in devenv.exe.config:

<dependentAssembly>
   <assemblyIdentity name="System.Management.Automation" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
    <publisherPolicy apply="no" />
   </dependentAssembly>

Thanks, Rohit Agrawal NuGet Team

1 Comment

This is still relevant as of version 15.9.3. It's not yet been fixed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.