【发布时间】:2016-08-13 17:55:20
【问题描述】:
我有兴趣为当前选择获取一个 Project 或 ProjectItem(例如,不限于这两个),其中仅选择了一个项目。
大多数人似乎都在使用IVsMonitorSelection 来获取IVSHierarchy,然后使用以下内容来获取所选项目的对象(如果选择了单个项目):
var monitorSelection = (IVsMonitorSelection) Package.GetGlobalService(typeof(IVsMonitorSelection));
IntPtr hierarchyPointer, selectionContainerPointer;
uint projectItemId;
IVsMultiItemSelect multiItemSelect;
monitorSelection.GetCurrentSelection(out hierarchyPointer, out projectItemId, out multiItemSelect, out selectionContainerPointer);
var hierarchy = (IVsHierarchy) Marshal.GetObjectForIUnknown(hierarchyPointer);
Marshal.Release(hierarchyPointer);
Marshal.Release(selectionContainerPointer);
object o;
hierarchy.GetProperty((uint) projectItemId, (int) __VSHPROPID.VSHPROPID_ExtObject, out o);
但是,GetProperty 在此处返回 E_NOTIMPL。我使用了错误的参数吗?是否有替代解决方案?
【问题讨论】:
标签: c# visual-studio com visual-studio-2015 vsix