Visual Studio 2017 - 无法初始化 powershell 主机 [英] Visual Studio 2017 - Unable to initialize powershell host

查看:51
本文介绍了Visual Studio 2017 - 无法初始化 powershell 主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第一天:

系统:Windows 10微软 Visual Studio 社区 2017版本 15.5.5VisualStudio.15.Release/15.5.5+27130.2026

我有一个使用 WindowsAzure.Storage NuGet 包的网站项目.

在 Visual Studio 中,我执行以下操作:

工具 ->NuGet 包管理器 ->管理解决方案的 NuGet 包...

系统显示有 2 个可用更新:

Newtonsoft.Json v10.0.3(目前安装的是v9.0.1)WindowsAzure.Storage v9.0(目前安装的是v8.7)

我选择选中选择所有包"复选框,然后单击更新"按钮.

失败(以前从未发生过)!!

以下是从 Visual Studio 捕获的输出:

正在从nuget.org"检索包WindowsAzure.Storage 9.0.0"....加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3007) : Error in type "System.Security.AccessControl.ObjectSecurity": 例外:getter 方法应该是公共的、非空的、静态的,并且有一个 PSObject 类型的参数.加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3014) : Error in type "System.Security.AccessControl.ObjectSecurity": 例外:getter 方法应该是公共的、非空的、静态的,并且有一个 PSObject 类型的参数.加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3021) : Error in type "System.Security.AccessControl.ObjectSecurity": 例外:getter 方法应该是公共的、非空的、静态的,并且有一个 PSObject 类型的参数.加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3028) : Error in type "System.Security.AccessControl.ObjectSecurity": 例外:getter 方法应该是公共的、非空的、静态的,并且有一个 PSObject 类型的参数.加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3035) : Error in type "System.Security.AccessControl.ObjectSecurity": 例外:getter 方法应该是公共的、非空的、静态的,并且有一个 PSObject 类型的参数.术语Get-ExecutionPolicy"不被识别为 cmdlet、函数、脚本文件或可运行程序的名称.检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试.安装失败.滚回来...

错误列表窗口显示:

无法初始化 PowerShell 主机.如果您的 PowerShell 执行策略设置设置为 AllSigned,请先打开包管理器控制台以初始化主机.

Powershell 输出来自:Get-ExecutionPolicy -List 输出:

 范围执行策略----- ---------------机器策略未定义用户策略未定义进程未定义当前用户不受限制本地机器不受限制

NuGet 包本身或我的系统有问题吗?

我在寻找解决方案之前和之后都从未遇到过这个问题(目前还没有找到)——我任由 NuGet/Visual Studio 之神摆布!

提前致谢.

======

第 2 天:上午 8:00 ...

再试一次...让我们看看我们是否可以让包管理器控制台工作...

启动 Visual Studio(社区 2017)

工具 ->NuGet 包管理器 ->包管理器控制台

结果显示如下:

加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3007) : Error in type "System.Security.AccessControl.ObjectSecurity":例外:getter 方法应该是公共的、非空的、静态的,并且有一个 PSObject 类型的参数.加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3014) : Error in type "System.Security.AccessControl.ObjectSecurity": 例外:getter 方法应该是公共的、非空的、静态的,并且有一个 PSObject 类型的参数.加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3021) : Error in type "System.Security.AccessControl.ObjectSecurity": 例外:getter 方法应该是公共的、非空的、静态的,并且有一个 PSObject 类型的参数.加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3028) : Error in type "System.Security.AccessControl.ObjectSecurity": 例外:getter 方法应该是公共的、非空的、静态的,并且有一个 PSObject 类型的参数.加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3035) : Error in type "System.Security.AccessControl.ObjectSecurity": 例外:getter 方法应该是公共的、非空的、静态的,并且有一个 PSObject 类型的参数.术语Get-ExecutionPolicy"不被识别为 cmdlet、函数、脚本文件或可运行程序的名称.检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试.

回到绘图板!将继续寻找解决方案...

那么,让我们试试 Visual Studio 安装程序...

启动 Visual Studio 安装程序选择更多"->修理"

结果:

找不到依赖包:Component.PowerShellTools.VS2017,version=3.0.585

我点击查看日志",显示:

[1cb4:000a][2018-02-17T08:27:06] 错误 0x80131500:找不到依赖包:Component.PowerShellTools.VS2017,version=3.0.585在 Microsoft.VisualStudio.Setup.Dependencies.DependencyManager.FindDependentPackages(Dependency dependency, DependencyComparer comparer, Dictionary`2 packageIndex)在 Microsoft.VisualStudio.Setup.Dependencies.DependencyManager.BuildGraphRecursive(IPPackage graphRoot,DependencyNode 节点,DependencyComparer 比较器,Dictionary`2 packageIndex,Dictionary`2 nodeIndex,Boolean splitNodes)在 Microsoft.VisualStudio.Setup.Dependencies.DependencyManager.BuildGraphCore(IPPackage 根、IEnumerable`1 包、DependencyComparer 比较器、Dictionary`2 packageIndex、Dictionary`2 nodeIndex、Boolean splitNodes、DependencyCollection 已弃用)在 Microsoft.VisualStudio.Setup.Dependencies.DependencyManager.BuildGraph(IPPackage 根,IEnumerable`1 包,布尔值 isUpdate,IDependencyComparisonSeed 种子,DependencyCollection 已弃用)在 Microsoft.VisualStudio.Setup.Engine.GetDependencyGraph(产品产品)在 Microsoft.VisualStudio.Setup.Engine.PreChecks(String installationPath, Boolean isLayoutSet, Product product, ExecuteAction bootstrapperAction, ITelemetryOperation operation, IQuery query)在 Microsoft.VisualStudio.Setup.Engine.Repair(CancellationToken 令牌)

好的 - 所以不知何故,我的系统丢失了一个依赖包(Component.PowerShellTools.VS2017) - 将尝试修改以查看我是否可以添加该包...

======

第 2 天 - 上午 10 点 15 分(仍在进行中)- 当前状态 - 机智结束...

Microsoft Visual Studio 社区 2017版本 15.5.6VisualStudio.15.Release/15.5.6+27130.2027微软 .NET 框架版本 4.7.02556

我执行以下操作:

工具 ->NuGet 包管理器 ->包管理器控制台

结果显示如下:

如果有人(微软)有解决方案——我真的很感激!

======

第 2 天:下午 3:09 ...

在最后一次(绝望的)尝试中,我启动了 Visual Studio 安装程序

点击更多"->修理" ....

几个小时后(重新)安装了 Visual Studio:

Microsoft Visual Studio 社区 2017版本 15.5.6VisualStudio.15.Release/15.5.6+27130.2027微软 .NET 框架版本 4.7.02556

然后我执行以下操作(在点燃 12 根蜡烛并高呼Bill-Bill-Bill"之后)...

工具 ->NuGet 包管理器 ->NuGet 管理器控制台

结果:

加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3007) : Error in type "System.Security.AccessControl.ObjectSecurity":例外:getter 方法应该是公共的、非空的、静态的,并且有一个 PSObject 类型的参数.加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3014) : Error in type "System.Security.AccessControl.ObjectSecurity": 例外:getter 方法应该是公共的、非空的、静态的,并且有一个 PSObject 类型的参数.加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3021) : Error in type "System.Security.AccessControl.ObjectSecurity": 例外:getter 方法应该是公共的、非空的、静态的,并且有一个 PSObject 类型的参数.加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3028) : Error in type "System.Security.AccessControl.ObjectSecurity": 例外:getter 方法应该是公共的、非空的、静态的,并且有一个 PSObject 类型的参数.加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3035) : Error in type "System.Security.AccessControl.ObjectSecurity": 例外:getter 方法应该是公共的、非空的、静态的,并且有一个 PSObject 类型的参数.术语Get-ExecutionPolicy"不被识别为 cmdlet、函数、脚本文件或可运行程序的名称.检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试.

我注定失败 -- 在此问题得到解决之前,我无法使用 Visual Studio.

======

第 3 天 - 上午 7:49

我看到我的问题已被 MSFT 分类:

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

还尝试了这些资源中的解决方案":

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

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

遗憾的是,上述方法均无助于解决此问题.

大多数帖子都表明可能需要完全重新安装 VS —— 真遗憾!!

希望能找到不需要完全重新安装的解决方案!

======

第 3 天 - 下午 1:54

放弃...

  1. 已卸载 Visual Studio.关闭(关闭系统)
  2. 启动(启动系统)
  3. 从以下位置下载 Visual Studio 安装程序https://www.visualstudio.com/downloads/
  4. 按照安装程序的说明运行磁盘清理应用.
  5. 关闭(关闭系统)
  6. 启动(启动系统)
  7. 运行 Visual Studio 2017 社区安装程序 - 成功.
  8. 启动 Visual Studio
  9. 工具 -> NuGet 包管理器 -> 包管理器控制台

结果:

加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3007) : Error in type "System.Security.AccessControl.ObjectSecurity":例外:getter 方法应该是公共的、非空的、静态的,并且有一个 PSObject 类型的参数.加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3014) : Error in type "System.Security.AccessControl.ObjectSecurity": 例外:getter 方法应该是公共的、非空的、静态的,并且有一个 PSObject 类型的参数.加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3021) : Error in type "System.Security.AccessControl.ObjectSecurity": 例外:getter 方法应该是公共的、非空的、静态的,并且有一个 PSObject 类型的参数.加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3028) : Error in type "System.Security.AccessControl.ObjectSecurity": 例外:getter 方法应该是公共的、非空的、静态的,并且有一个 PSObject 类型的参数.加载扩展类型数据文件时出现以下错误:Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3035) : Error in type "System.Security.AccessControl.ObjectSecurity": 例外:getter 方法应该是公共的、非空的、静态的,并且有一个 PSObject 类型的参数.术语Get-ExecutionPolicy"不被识别为 cmdlet、函数、脚本文件或可运行程序的名称.检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试.

所以 - 即使是全新安装的 Visual Studio Community 也无法解决这个问题!!!

======

第 4 天 - 上午 9:11

昨晚我在 GitHub re PowerShell 上打开了一个新问题,请参阅:

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

今天早上找到回复,采纳了lzybkr的建议,禁用了Powershell V2;我在上面的 GitHub 帖子上发布了禁用 V2 的命令.

好消息 - 我可以再次通过 NuGet 更新包!

坏消息 - 如果我启动 Visual Studio 然后执行:

工具 ->NuGet 包管理器 ->包管理器控制台

控制台窗口打开,但只是挂起并显示以下消息:

正在初始化 Powershell 主机...

我仍然不知道是什么导致了 Visual Studio 中的这种行为;但 4 天后,我觉得自己很幸运,我可以(再次)更新 NuGet 包并重新开始工作.

虽然我更新 NuGet 包的问题"(大部分)已经解决,但我仍然不认为这是一个解决方案,因为 Visual Studio/NuGet 包管理器控制台无法初始化 PowerShell 主机的根本原因有未解决.

如果有人找到根本原因,请发布您的解决方案.

解决方案

下面终于解决了上面描述的问题:

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

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:

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://docs.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.

解决方案

The following finally solved the problem described above:

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

这篇关于Visual Studio 2017 - 无法初始化 powershell 主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆