在 VS 解决方案中有以下结构:
现在,我想获取对“Catalogs”文件夹的引用并将其存储在变量中:
//Solution_Name
// ConfigurationObjects
// Catalogs
// Documents
foreach (Project item1 in AttachedSolution.Projects)
{
if (item1.Kind == ProjectKinds.vsProjectKindSolutionFolder)
{
if (item1.Name == "ConfigurationObjects")
{
SolutionFolder catalogBaseFolder = (SolutionFolder)item1.Object;
foreach (ProjectItem item2 in item1.ProjectItems)
{
if ( item2.Name == "Catalogs")
{
this.CatalogObjectsFolder = (SolutionFolder)item2;
// raises error here: Unable to cast COM object of type
//'System.__ComObject'
//to interface type 'EnvDTE80.SolutionFolder'.
};
};
};
};
};
感谢您的帮助。
我是一名优秀的程序员,十分优秀!