Hi Tamir,
If you want to be notified when the developer are invoking "Add Reference"
dialog, you should write an add-in for your IDE.
In the OnConnection method, you may get the "Add Reference" command, then
you can add event handler for this command, do like this:
applicationObject = (DTE)application;
addInInstance = (AddIn)addInInst;
Command addref_cmd=null;
foreach(Command cmd in applicationObject.Commands)
{
if(cmd.Name!=null)
{
if(cmd.Name.Equals("Project.AddReference"))
{
addref_cmd=cmd;
}
}
}
if(addref_cmd!=null)
{
CommandEvents
objAddReferenceCommandEvents=applicationObject.Events.get_CommandEvents(addr
ef_cmd.Guid, addref_cmd.ID);
objAddReferenceCommandEvents.BeforeExecute+=new
_dispCommandEvents_BeforeExecuteEventHandler(objAddReferenceCommandEvents_Be
foreExecute);
}
else
{
System.Windows.Forms.MessageBox.Show("You did not refered the command!!");
}
private void objAddReferenceCommandEvents_BeforeExecute(string Guid, int
ID, object CustomIn, object CustomOut, ref bool CancelDefault)
{
System.Windows.Forms.MessageBox.Show("You invoked add
reference!");
}
If you want to determine when the actual reference is adding to the
project, you should use another approach:
First, add VSLangProj reference in your add-in project.
Then, You should convert your DTE.Solution.Projects(0).Object to
VSLangProj.VSProject,
At last, use ReferenceAdded event of
VSLangProj.VSProject.Events.ReferencesEvents object.
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.