REGDB_E_CLASSNOTREG error/resolution while launching PowerShell from C# code
The following error is highlighted in this StackExchange thread and the most common solution is to ensure that PowerShell is opened from Windows Start menu and PowerShell exe must point to this path: %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
What-if you get the error while launching PowerShell from C# code. This is kind of an edge case and not covered anywhere. In my situation, I launched PowerShell from my C# code as per this StackExchange answer and just for reference here is the method that invoked the PowerShell prompt/script:
//////////
public static void LaunchPSScript(string scriptname,string workingDirectory=".")
{
var script = scriptname;
var startInfo = new ProcessStartInfo()
{
FileName = @"powershell.exe",
WorkingDirectory = workingDirectory,
Arguments = $"-NoProfile -noexit -ExecutionPolicy Bypass \"{script}\"",
UseShellExecute = false
};
Process.Start(startInfo);
}
/////////
Moreover, the above was working code and started throwing the following error all of a sudden. To add to the confusion, between the last time it was working and now, I had switched over to Windows 11 Pro but unsure if the new OS was the issue. I also checked launching PowerShell from Start menu in the new Windows 11 Pro machine and the same script worked fine with the PS exe location pointing to %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe. So, in summary, Windows 11 Pro wasn't the issue. Also, I could see that the C# program launched PowerShell from the same location but error-ed in the middle as per the following screen shot.
[---------------------------- IdentityServer_CreateAppPool : AppPool -------------------------------------------------]
Install-SitecoreConfiguration : Cannot retrieve the dynamic parameters for the cmdlet. Retrieving the COM class factory for component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
+ Install-SitecoreConfiguration @singleDeveloperParams *>&1 | Tee-Obje ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Install-SitecoreConfiguration
[TIME] 00:00:12
Invoke-AppPoolTask : Cannot retrieve the dynamic parameters for the cmdlet. Retrieving the COM class factory for
component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154 Class not
registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
At C:\Program
Files\WindowsPowerShell\Modules\SitecoreInstallFramework\2.3.0\Public\Install-SitecoreConfiguration.ps1:641 char:25
+ & $entry.Task.Command @paramSet | Out-Default
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-AppPoolTask], ParameterBindingException
+ FullyQualifiedErrorId : GetDynamicParametersException,Invoke-AppPoolTask
Comments
Post a Comment