I have implemented my custom project type and I am now trying to capture events when ProjectItems from a project are renamed.
I tried below codes which is mostly used for an Add-In application in the Initialize() method of my VSPackage, however, it does not work in my VSPackage.
Could someone tell me why it does not work? And how I can subscribe the ProjectItem rename method in a VSPackage class?
DTE2 dte2 = (this as System.IServiceProvider).GetService(typeof(DTE)) as DTE2;
((Events2)(dte2.Events)).ProjectItemsEvents.ItemRenamed += new _dispProjectItemsEvents_ItemRenamedEventHandler(ProjectItemsEvents_ItemRenamed);