使用PowerShell脚本安装COM +组件中的问题 [英] Issues in installing COM + Component using PowerShell script
问题描述
我正在尝试使用Powershell安装COM +组件.但是我遇到了以下错误.
I'm trying to install COM + Component using powershell. But I'm getting following error.
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脚本:
and here is my powershell script:
$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有人可以帮我吗?
My powershell version is 4.0 Can someone please help me on this.
谢谢.
推荐答案
PowerShell中的方括号表示类型,例如 [string]
或 [int32]
或 [System.Array]
或 [System.Math]
.该错误消息是抱怨的,因为您告诉PowerShell COMITSServer.dll是已注册并已加载的数据类型.
Square brackets in PowerShell indicate a type, like [string]
or [int32]
or [System.Array]
or [System.Math]
. The error message is complaining because you're telling PowerShell that COMITSServer.dll is a registered and loaded data type.
另外,对我来说, COMAdminCatalog
的 InstallComponent
方法似乎具有四个参数,而不是两个.您应该可以通过查看定义来确认这一点,但是我不知道v2.0是否支持这样做:
Additionally, the InstallComponent
method of COMAdminCatalog
appears to me to have four arguments, not two. You should be able to confirm that by looking at the definition, but I don't know if v2.0 supports doing it like this:
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)
这样,我会尝试这样做:
As such, I would try this:
$comAdmin.InstallComponent("ITSServerOO2", "COMITSServer.dll", "", "");
That appears to be how the VB code here calls the same method:
' 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是否相同.
Here is the class definition of that function, I believe, athough I'm not familiar enough with COM+ to know if COMAdminCatalog and ICOMAdminCatalog are the same.
这篇关于使用PowerShell脚本安装COM +组件中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!