[英]How can I get a list of all the com+ components of a com+ application?
I am trying to work with COM+ using c# and ASP.NET. 我正在尝试使用c#和ASP.NET来使用COM +。 I have been following an example , however part of it fails. 我一直在关注一个例子 ,但其中一部分失败了。
dynamic oCatalog = Activator.CreateInstance(Type.GetTypeFromProgID("ComAdmin.COMAdminCatalog"));
/* Get the Applications collection and populate it */
dynamic applicationInstances = oCatalog.GetCollection("Applications");
applicationInstances.Populate();
foreach (dynamic applicationInstance in applicationInstances)
{
Response.Write("<p>" + applicationInstance.Name.ToString() + "-" + applicationInstance.Key.ToString() + "</p>");
dynamic objComponents = oCatalog.GetCollection("Components", applicationInstance.Key);
objComponents.Populate();
foreach(dynamic Components in objComponents)
{
Response.Write("<p>" + Components.Name.ToString() + "</p>");
}
}
When the above call oCatalog.GetCollection("Components", applicationInstance.Key) is called I get the error: 当上面调用oCatalog.GetCollection(“Components”,applicationInstance.Key)被调用时,我得到错误:
System.Reflection.TargetParameterCountException: Error while invoking GetCollection. System.Reflection.TargetParameterCountException:调用GetCollection时出错。
How can I get a list of the current components in an application instance? 如何获取应用程序实例中的当前组件列表?
You need to ask the "applications" collection for the components for an specific application: 您需要为特定应用程序的组件询问“applications”集合:
ICOMAdminCatalog2 oCatalog = (ICOMAdminCatalog2) Activator.CreateInstance(Type.GetTypeFromProgID("ComAdmin.COMAdminCatalog"));
ICatalogCollection applications = oCatalog.GetCollection("Applications");
applications.Populate();
foreach (ICatalogObject applicationInstance in applications)
{
ICatalogCollection comps = applications.GetCollection("Components", applicationInstance.Key);
comps.Populate();
foreach (ICatalogObject comp in comps)
{
Console.WriteLine("{0} - {1}", comp.Name, comp.Key);
}
}
for an example check here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms686093(v=vs.85).aspx 有关示例,请访问: http : //msdn.microsoft.com/en-us/library/windows/desktop/ms686093(v = vs。85).aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.