Getting factory COM class for component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed

I am creating an application that stops the default IIS website. I used a PowerShell script to stop the website because this script is being executed from my website.

This is my script:

Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Modules\WebAdministration Stop-Website 'Default Web Site' my copy code Start-Website 'Default Web Site' 

And this is my C # code:

 PowerShell _PowerShell = PowerShell.Create(); Runspace rs = RunspaceFactory.CreateRunspace(); rs.Open(); _PowerShell.Runspace = rs; _PowerShell.AddScript(@"Set-ExecutionPolicy RemoteSigned -scope LocalMachine").Invoke(); _PowerShell.AddScript(@"E:\DE.TEST\Power_Shell\Scripts\StopIISDefaultSite.ps1").Invoke(); if (_PowerShell.HadErrors) { Collection<ErrorRecord> errors = _PowerShell.Streams.Error.ReadAll(); foreach (var item in errors) { Console.WriteLine(item.ToString()); } } Console.ReadLine(); 

The following error is displayed

Retrieving the factory COM class for a 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)).

+5
source share
1 answer

You need to check if the PowerShell instance is running under your PS code, 32-bit or 64-bit, and create a solution for this target platform. You can verify this using:

 if([IntPtr]::size -eq 8) { Write-Host 'x64' } else { Write-Host 'x86' } 

A source

As stated in the comment proposal, if you are using the 64-bit version of PowerShell, you create your solution for AnyCPU and uncheck the "Prefer 32-bit version" box.

+6
source

All Articles