Retrieving the COM class factory for component with CLSID {E1765667-2EE4-464B-B00D-42EB84631C48} failed due to the following error: 80080005 Server execution failed
Issue
After powerJobs Processor(PJP) has been running for multiple hours, when converting AutoCAD drawing with the Sample.CreatePDF job fails with COM exception 0x80080005.
In the windows task manager multiple processes with the name "dwgviewr.exe" can be seen.
The PJP log file contains the following error:
powerJobs.Application.TrueView.Application - DWG TrueView: Failed to initialize application!
System.Runtime.InteropServices.COMException (0x80080005): Retrieving the COM class factory for component with CLSID {E1765667-2EE4-464B-B00D-42EB84631C48} failed due to the following error: 80080005 Server execution failed
Cause
Currently under investigation
Solution
To get around this issue we will create a time triggered job that cleans up TrueView processes if there are more than one. This will take care of the issue when no other jobs are running.
Additionally we will extend the existing jobs with the same functionality to ensure processes aren't adding up when a lot of jobs are queued.
Create the file "C:\ProgramData\coolOrange\powerJobs\Modules\TrueViewNotClosingWorkaround.psm1" with the following content
function StopTrueViewProcesses {
Write-Host '>> StopTrueViewProcesses >>'
$processJobProcessor = Get-Process -Name Connectivity.JobProcessor.Delegate.Host -IncludeUserName
$start = [DateTime]::Now
while(([DateTime]::Now - $start).TotalSeconds -lt 10) {
$processes = Get-Process -Name 'dwgviewr' -IncludeUserName -ErrorAction SilentlyContinue `
| Where-Object { $_.UserName -eq $processJobProcessor.UserName }
if($processes.Count -le 1) {
Write-Host '<< StopTrueViewProcesses <<'
return
}
Start-Sleep -Seconds 1
}
Write-Host "Found '$($processes.Count)' TrueView processes"
Write-Host "Stopping current 'DWG TrueView' application"
$dwgTrueView = Get-Application -Application 'DWG TrueView'
if($dwgTrueView) {
$dwgTrueView.Stop()
$dwgTrueView.Dispose()
}
$processes = Get-Process -Name 'dwgviewr' -IncludeUserName -ErrorAction SilentlyContinue `
| Where-Object { $_.UserName -eq $processJobProcessor.UserName }
foreach($process in $processes) {
Write-Host "Stop-Process $($process.Id)"
Stop-Process -InputObject $process -ErrorAction SilentlyContinue
}
Start-Sleep -Seconds 5
Write-Host '<< StopTrueViewProcesses <<'
}
The following function checks if there are more than one open TrueView processes and then closes the currently used one cleanly and kills all remaining processes. The function checks for 10 seconds if multiple processes exist as it takes some time for them to close sometimes and still might close by themselves.
Also create the file "C:\ProgramData\coolOrange\powerJobs\Jobs\TrueViewNotClosingWorkaround.ps1" with the following content
Write-Host '>> Start Job TrueViewNotClosingWorkaround >>'
StopTrueViewProcesses
Write-Host '<< End Job TrueViewNotClosingWorkaround <<'
And the file "C:\ProgramData\coolOrange\powerJobs\Jobs\TrueViewNotClosingWorkaround.ps1" with the following content.
{
"Trigger":
{
"TimeBased": "0 0/30 * 1/1 * ? *",
"Vault":"Vault",
// And this two parameters are optional and self explaining:
"Priority":10,
"Description":"Cleans up TrueView instances every 30 minutes."
}
}
If your vault is not called "Vault" change the line
"Vault":"Vault",
to
"Vault":"yourVaultName",
Now you just need to call the function before Open-Document in every job that handles AutoCAD drawings. For example
StopTrueViewProcesses
$openResult = Open-Document -LocalFile $filePath