Sharepoint - Error occurred in deployment step 'Recycle IIS Application Pool': Invalid namespace
Apparently, VS 2010 uses WMI to control IIS during a redeploy. Without the features enabled, I got the same "Invalid namespace" error.
The solution was to: open the Turn Windows Features on or off menu in the Control Panel (under Programs), and enable WMI compatibility. The path to the feature is:
Internet Information Services -> Web Management Tools -> IIS 6 Management Compatibility -> IIS 6 WMI Compatibility
Same problem with VS2019 and Windows Server 2019.
In modern Windows here's the solution: