public override int AddProjectReference()
{
IVsComponentSelectorDlg2 componentDialog;
Guid startOnTab = Guid.Empty;
VSCOMPONENTSELECTORTABINIT[] tabInit = new VSCOMPONENTSELECTORTABINIT[5];
string browseLocations = Path.GetDirectoryName(BaseURI.Uri.LocalPath);
Guid GUID_MruPage = new Guid("{19B97F03-9594-4c1c-BE28-25FF030113B3}");
// Add the .NET page.
//
tabInit[0].dwSize = (uint)Marshal.SizeOf(typeof(VSCOMPONENTSELECTORTABINIT));
tabInit[0].varTabInitInfo = 0;
tabInit[0].guidTab = VSConstants.GUID_COMPlusPage;
// Add the COM page.
//
tabInit[1].dwSize = (uint)Marshal.SizeOf(typeof(VSCOMPONENTSELECTORTABINIT));
tabInit[1].varTabInitInfo = 0;
tabInit[1].guidTab = VSConstants.GUID_COMClassicPage;
// Add the Project page.
//
tabInit[2].dwSize = (uint)Marshal.SizeOf(typeof(VSCOMPONENTSELECTORTABINIT));
// Tell the Add Reference dialog to call hierarchies GetProperty with
// the following propID to enable filtering out ourself from the Project
// to Project reference
tabInit[2].varTabInitInfo = (int)__VSHPROPID.VSHPROPID_ShowProjInSolutionPage;
tabInit[2].guidTab = VSConstants.GUID_SolutionPage;
// Add the Browse page.
//
tabInit[3].dwSize = (uint)Marshal.SizeOf(typeof(VSCOMPONENTSELECTORTABINIT));
tabInit[3].varTabInitInfo = 0;
tabInit[3].guidTab = VSConstants.GUID_BrowseFilePage;
// Add the Recent page.
//
tabInit[4].dwSize = (uint)Marshal.SizeOf(typeof(VSCOMPONENTSELECTORTABINIT));
tabInit[4].varTabInitInfo = 0;
tabInit[4].guidTab = GUID_MruPage;
uint pX = 0, pY = 0;
startOnTab = tabInit[2].guidTab;
componentDialog = GetService(typeof(SVsComponentSelectorDlg)) as IVsComponentSelectorDlg2;
try
{
// Call the container to open the add reference dialog.
//
if (componentDialog != null)
{
// Let the project know not to show itself in the Add Project Reference Dialog page
//
ShowProjectInSolutionPage = false;
// Call the container to open the add reference dialog.
//
ErrorHandler.ThrowOnFailure(
componentDialog.ComponentSelectorDlg2(
(UInt32)
(__VSCOMPSELFLAGS.VSCOMSEL_MultiSelectMode |
__VSCOMPSELFLAGS.VSCOMSEL_IgnoreMachineName),
this,
0,
null,
// Title
Microsoft.VisualStudio.Project.SR.GetString(
Microsoft.VisualStudio.Project.SR.AddReferenceDialogTitle),
"VS.AddReference", // Help topic
ref pX,
ref pY,
(uint)tabInit.Length,
tabInit,
ref startOnTab,
"*.dll",
ref browseLocations));
}
}
catch (COMException e)
{
Trace.WriteLine("Exception : " + e.Message);
return e.ErrorCode;
}
finally
{
// Let the project know it can show itself in the Add Project Reference Dialog page
//
ShowProjectInSolutionPage = true;
}
return VSConstants.S_OK;
}