Visual Studio 2019 PowerShell主机初始化失败问题求助(常规解决方案无效)
Hey there, let's break down why your existing fixes aren't working and walk through the actual solution to this frustrating issue.
The Root Cause
Here's the key detail you might have missed: Visual Studio 2019 is a 32-bit application, which means it uses the 32-bit version of PowerShell under the hood. When you ran Set-ExecutionPolicy Unrestricted in a regular PowerShell window, you only modified the policy for the 64-bit environment—your 32-bit PowerShell was still stuck on AllSigned, which is exactly what that start-job command revealed (it runs the command in a 32-bit context).
Step-by-Step Solution
Follow these steps to fix the 32-bit PowerShell execution policy:
- Open the 32-bit PowerShell as Administrator:
Navigate toC:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe, right-click it, and select Run as administrator. - Set the execution policy for 32-bit PowerShell:
Run this command in the 32-bit window:
When prompted, typeSet-ExecutionPolicy UnrestrictedYand press Enter to confirm the change. - Verify the change:
RunGet-ExecutionPolicyin the same window—you should seeUnrestrictedreturned. - Restart Visual Studio:
Close and reopen VS 2019, then try creating your Web Forms project or installing the AWS DynamoDB SDK NuGet package again.
Additional Troubleshooting Tips
If the above doesn't resolve the issue right away, try these extra steps:
- Manually initialize the Package Manager Console: Open Tools > NuGet Package Manager > Package Manager Console. Sometimes just opening this window triggers the PowerShell host initialization process, which can fix underlying issues.
- Clear NuGet Cache: Go to Tools > Options > NuGet Package Manager > General, then click Clear All NuGet Cache(s). Corrupted cache files can sometimes interfere with package installations.
- Check for Visual Studio Updates: Make sure your VS 2019 is fully updated—Microsoft has released patches for PowerShell host-related bugs in older versions.
内容的提问来源于stack exchange,提问作者AGlasencnik

