首页 > 解决方案 > Windows Server 无头安装无法管理 COM+ 组件

问题描述

我已经研究了很长时间,似乎有些人也这样做了。参考 1参考2

免责声明:

我正在将一些遗留应用程序迁移到 docker,并且存在 COM+ 依赖项。桌面体验安装没有问题,但在服务器的无头安装中,(物理、虚拟机或 docker 容器)COM+ 安装/管理不起作用。

列出所有组件,我得到这个响应。请注意,COMEXPS.CTrkEvntListener.1这是COM+ Explorer应用程序的一部分返回错误:

PS C:\> $comAdmin = New-Object -com ("COMAdmin.COMAdminCatalog")
PS C:\> $applications = $comAdmin.GetCollection("Applications")
PS C:\> $applications.Populate()
PS C:\> foreach ($application in $applications)
>> {
>>     $components = $applications.GetCollection("Components",$application.key)
>>     $components.Populate()
>>     foreach ($component in $components)
>>     {
>>
>>         $dllName = $component.Value("DLL")
>>         $componentName = $component.Name
>>
>>         "Component Name:$componentName"
>>         "DllName: $dllName`n"
>>     }
>> }
Component Name:RemoteHelper.RemoteHelper
DllName: C:\Windows\system32\stclient.dll

Component Name:TxCTx.TransactionContext
DllName: C:\Windows\System32\comsvcs.dll

Component Name:TxCTx.TransactionContextEx
DllName: C:\Windows\System32\comsvcs.dll
Component Name:QC.Recorder
DllName: C:\Windows\System32\comsvcs.dll

Component Name:QC.ListenerHelper
DllName: C:\Windows\System32\comsvcs.dll

Component Name:QC.DLQListener
DllName: C:\Windows\System32\comsvcs.dll

Errors occurred accessing one or more objects - the ErrorInfo collection may have more detail
(Exception from HRESULT: 0x80110401)
At line:5 char:5
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException

Component Name:COMEXPS.CTrkEvntListener.1
DllName:

Component Name:RemoteHelper.RemoteHelper
DllName: C:\Windows\system32\stclient.dll

Component Name:TxCTx.TransactionContext
DllName: C:\Windows\SysWOW64\comsvcs.dll

Component Name:TxCTx.TransactionContextEx
DllName: C:\Windows\SysWOW64\comsvcs.dll

Component Name:QC.Recorder
DllName: C:\Windows\SysWOW64\comsvcs.dll

Component Name:QC.ListenerHelper
DllName: C:\Windows\SysWOW64\comsvcs.dll

Component Name:Catsrv.CatalogServer
DllName: C:\Windows\system32\catsrv.dll

Component Name:EventPublisher.EventPublisher
DllName: C:\Windows\System32\comsvcs.dll

DllName: C:\Windows\System32\comsvcs.dll

Component Name:Mts.MtsGrp
DllName: C:\Windows\System32\comsvcs.dll

Component Name:Pdump.ProcessDump
DllName: C:\Windows\System32\comsvcs.dll

所以,除了 line 之前的错误Component Name:COMEXPS.CTrkEvntListener.1,一切都是默认的。您还可以将应用程序添加到 COM+ 注册表:

PS C:\Windows\System32> $comAdmin = New-Object -comobject COMAdmin.COMAdminCatalog
PS C:\Windows\System32> $apps = $comAdmin.GetCollection("Applications")
PS C:\Windows\System32> $apps.Populate();
PS C:\Windows\System32> $applicationName= "ApplicationName"
PS C:\Windows\System32> $appExistCheckApp = $apps | Where-Object {$_.Name -eq $applicationName}
PS C:\Windows\System32> $newApp1 = $apps.Add()
PS C:\Windows\System32> $newApp1.Value("Name") = $applicationName
PS C:\Windows\System32> $newApp1.Value("Identity") = "nt authority\localservice"
PS C:\Windows\System32> $apps.SaveChanges()
1
PS C:\Windows\System32>  $apps.Populate();
PS C:\Windows\System32> $apps

Key                                    Name                               Valid
---                                    ----                               -----
{9EB3B62C-79A2-11D2-9891-00C04F79AF51} COM+ Utilities                      True
{7B4E1F3C-A702-11D2-A336-00C04F7978E0} COM+ QC Dead Letter Queue Listener  True
{9E18F23F-72BD-44A2-8DC7-7B5CAECF5E21} ApplicationName                     True
{01885945-612C-4A53-A479-E97507453926} COM+ Explorer                       True
{6B97138E-3C20-48D1-945F-81AE63282DEE} COM+ Utilities (32 bit)             True
{02D4B3F1-FD88-11D1-960D-00805FC79235} System Application                  True

这实际上工作正常,您可以看到ApplicationName已添加。问题是当您尝试将 DLL 组件添加到任何已配置的应用程序时:

PS C:\> $installResults = $comAdmin.InstallComponent("{9E18F23F-72BD-44A2-8DC7-7B5CAECF5E21}", " C:\mydll.dll", "", "");
(Exception from HRESULT: 0x80110401)
At line:1 char:1
+ $installResults = $comAdmin.InstallComponent("{9E18F23F-72BD-44A2-8DC ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException

或者

PS C:\> regsvr32 /s ./mydll.dll

第一次尝试返回错误,第二次尝试什么也不做。我注意到该错误与您列出组件时的错误相同。也许InstallComponent函数在某个时候调用这个列表并因为这个错误而失败。

我能够看到application并且component删除不起作用或被禁用:

PS C:\> $applications.Remove(3)
PS C:\> $applications.SaveChanges()
The delete function has been disabled for this object (Exception from HRESULT: 0x8011042B)
At line:1 char:1
+ $applications.SaveChanges()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException

PS C:\> $components.Remove(0)
PS C:\> $components.SaveChanges()
Errors occurred accessing one or more objects - the ErrorInfo collection may have more detail
(Exception from HRESULT: 0x80110401)
+ $components.SaveChanges()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException

重要提示:在组件列表中返回的相同错误也会在InstallComponentSaveChanges函数中返回。也许是因为同样的原因。(?)

我可以在带有桌面 UI 的 Windows Server 中将此组件跟踪到 DLL。我检查了这个 DLLs 依赖项,似乎它们都在图像中,但是缺少组件的依赖项:

PS C:\> ls C:\Windows\System32\comuid.dll
ls : Cannot find path 'C:\Windows\System32\comuid.dll' because it does not exist.
At line:1 char:1
+ ls C:\Windows\System32\comuid.dll
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Windows\System32\comuid.dll:String) [Get-ChildItem], ItemNotFou
   ndException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

但即使将此 DLL 复制到缺少它的机器或映像,错误仍然存​​在。似乎原始图像中没有文件使组件保持在失败状态:

PS C:\> $component

Key                                    Name                       Valid
---                                    ----                       -----
{2C3E140B-7A0D-42D1-B2AA-D343500A90CF} COMEXPS.CTrkEvntListener.1 False

此外,因此该错误是由不应该存在于非桌面环境中的 COM+ Explorer DLL 引起的。至少我认为。

我很乐意提供有关该问题的任何其他信息。

非常感谢!

标签: windows-serverserver-core

解决方案


推荐阅读