我正在尝试使用powershell安装COM +组件。但我会跟着错误走。
Unable to find type [some.dll]. Make sure that the assembly that contains this
type is loaded.
+ $comAdmin.InstallComponent("test", [some.dll]);
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (COMITSServer.dll:TypeName) [], Runtime
Exception
+ FullyQualifiedErrorId : TypeNotFound下面是我的powershell脚本:
安装COM +组件
$comAdmin = New-Object -comobject COMAdmin.COMAdminCatalog;
$comAdmin.InstallComponent("some", [some.dll]);
#if an exception occurs in installing COM+ then display the message below
if (!$?)
{
Write-Host "Unable to Install the COM+ Component. Aborting..."
exit -1
}我的powershell版本是4.0,谁能帮我这个忙吗?
谢谢。
发布于 2015-12-18 14:07:01
PowerShell中的方括号表示类型,如[string]或[int32]、[System.Array]或[System.Math]。错误消息是在抱怨,因为您告诉PowerShell COMITSServer.dll是一个已注册和加载的数据类型。
此外,在我看来,COMAdminCatalog的COMAdminCatalog方法有四个参数,而不是两个。您应该能够通过查看定义来确认这一点,但我不知道v2.0是否支持这样做:
PS U:\> $comAdmin = New-Object -comobject COMAdmin.COMAdminCatalog
PS U:\> $comAdmin | gm | where { $_.Name -eq 'InstallComponent' }
TypeName: System.__ComObject#{790c6e0b-9194-4cc9-9426-a48a63185696}
Name MemberType Definition
---- ---------- ----------
InstallComponent Method void InstallComponent (string, string, string, string)因此,我会尝试这样做:
$comAdmin.InstallComponent("ITSServerOO2", "COMITSServer.dll", "", "");这似乎是VB代码这里调用相同方法的方式:
' Open a session with the catalog.
' Instantiate a COMAdminCatalog object.
Dim objCatalog As COMAdminCatalog
Set objCatalog = CreateObject("COMAdmin.COMAdminCatalog")
[...]
' Install components into the application.
' Use the InstallComponent method on COMAdminCatalog.
' In this case, the last two parameters are passed as empty strings.
objCatalog.InstallComponent "MyHomeZoo","MyZoo.DLL","","" 我相信,这里是该函数的类定义,尽管我对COM+还不太熟悉,不知道COMAdminCatalog和ICOMAdminCatalog是否相同。
发布于 2015-12-27 07:24:47
这是对0x80110401 HRESULT问题的回答。(顺便说一句,后续问题应在新的帖子中回答,而不是在现有问题的评论中回答)。这样,当其他人有相同的问题时,他们就可以找到答案。
ICOMAdminCatalog::InstallComponent文档。正如文档所解释的,第一个参数是GUID,第二个参数是正在注册的DLL。第三个参数(typelib)和第四个参数(代理存根DLL)是可选的,可以指定为空字符串。
"test“不是有效的GUID。注意,GUID是一个不同的.NET类型(System.Guid)。然而,文档需要一个BSTR,它将转换为一个System.String。要获得一个新的GUID作为字符串,请使用以下代码:[Guid]::NewGuid().toString()。
请注意,COM+组件的GUID是“众所周知的”值,由实现接口的COM服务器和从COM服务器消费接口的客户端使用。因此,通常您不希望在注册COM服务器时生成新的GUID,而是使用开发人员在开发COM服务器时创建的GUID。但是,如果您不知道正确的GUID是什么,那么生成一个新的GUID至少可以让您在开发脚本方面取得进展。
这可能修复或不修复导致0x80110401的问题,但它肯定会解决您迟早会遇到的问题。
https://stackoverflow.com/questions/34347166
复制相似问题