【发布时间】:2010-09-24 23:05:47
【问题描述】:
组件服务 -> 计算机 -> 我的电脑 -> COM+ 应用程序
打开一个 COM+ 应用程序对象。
打开组件。
右键单击一个类并选择属性。
在“高级”下有一个“允许 IIS 固有属性”复选框。
如何以编程方式选中此复选框?
我可以通过编程方式创建和删除 COM+ 应用程序,但 ComApplication 类似乎无法更改已创建应用程序中的设置。
【问题讨论】:
标签: .net components com+
组件服务 -> 计算机 -> 我的电脑 -> COM+ 应用程序
打开一个 COM+ 应用程序对象。
打开组件。
右键单击一个类并选择属性。
在“高级”下有一个“允许 IIS 固有属性”复选框。
如何以编程方式选中此复选框?
我可以通过编程方式创建和删除 COM+ 应用程序,但 ComApplication 类似乎无法更改已创建应用程序中的设置。
【问题讨论】:
标签: .net components com+
我知道怎么做。
显然我要获取COM+应用程序的集合,找到我想要的(按名称),然后获取应用程序中的组件集合,然后遍历集合并设置属性:
//get collection of applications
COMAdminCatalog catalog = new COMAdminCatalog();
catalog.Connect("127.0.0.1");
COMAdminCatalogCollection applications = (COMAdminCatalogCollection)catalog.GetCollection("Applications");
applications.Populate(); //no idea why that is necessary, seems to be
// appId for the application we are looking for
object appId = new object();
int count = applications.Count;
ICatalogObject item;
if (count == 0) return;
//search collection for item with name we are looking for
for (int i = 0; i < count; i++)
{
item = (ICatalogObject)applications.get_Item(i);
if (applicationName == (string)item.get_Value("Name"))
{
appId = item.Key;
Console.WriteLine("appId found for " + applicationName + ": " + appId.ToString());
}
}
// get all components for the application
COMAdminCatalogCollection components;
components = (COMAdminCatalogCollection)applications.GetCollection("Components", appId);
components.Populate(); // again, no idea why this is necessary
// set the attribute in all components
foreach (COMAdminCatalogObject component in components)
{
Console.WriteLine("Setting IISIntrinsics attribute in " + component.Name + ".");
component.set_Value("IISIntrinsics", true);
components.SaveChanges();
}
我认为这可以做得更好并且使用更少的演员表。但我不知道怎么做。
这样就可以了。
【讨论】:
我对这个特殊属性没有经验,但它似乎记录在 MSDN 中。
【讨论】: