public virtual int AddProjectReference()
{
CCITracing.TraceCall();
IVsComponentSelectorDlg4 componentDialog;
string strBrowseLocations = Path.GetDirectoryName(this.BaseURI.Uri.LocalPath);
var tabInitList = new List<VSCOMPONENTSELECTORTABINIT>()
{
new VSCOMPONENTSELECTORTABINIT {
guidTab = VSConstants.GUID_COMPlusPage,
varTabInitInfo = GetComponentPickerDirectories(),
},
new VSCOMPONENTSELECTORTABINIT {
guidTab = VSConstants.GUID_COMClassicPage,
},
new VSCOMPONENTSELECTORTABINIT {
// Tell the Add Reference dialog to call hierarchies GetProperty with the following
// propID to enablefiltering out ourself from the Project to Project reference
varTabInitInfo = (int)__VSHPROPID.VSHPROPID_ShowProjInSolutionPage,
guidTab = VSConstants.GUID_SolutionPage,
},
// Add the Browse for file page
new VSCOMPONENTSELECTORTABINIT {
varTabInitInfo = 0,
guidTab = VSConstants.GUID_BrowseFilePage,
},
new VSCOMPONENTSELECTORTABINIT {
guidTab = GUID_MruPage,
},
};
tabInitList.ForEach(tab => tab.dwSize = (uint)Marshal.SizeOf(typeof(VSCOMPONENTSELECTORTABINIT)));
componentDialog = this.GetService(typeof(IVsComponentSelectorDlg)) as IVsComponentSelectorDlg4;
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
this.ShowProjectInSolutionPage = false;
// call the container to open the add reference dialog.
string browseFilters = "Component Files (*.exe;*.dll)\0*.exe;*.dll\0";
ErrorHandler.ThrowOnFailure(componentDialog.ComponentSelectorDlg5(
(System.UInt32)(__VSCOMPSELFLAGS.VSCOMSEL_MultiSelectMode | __VSCOMPSELFLAGS.VSCOMSEL_IgnoreMachineName),
(IVsComponentUser)this,
0,
null,
SR.GetString(SR.AddReferenceDialogTitle, CultureInfo.CurrentUICulture), // Title
"VS.AddReference", // Help topic
addComponentDialogSizeX,
addComponentDialogSizeY,
(uint)tabInitList.Count,
tabInitList.ToArray(),
ref addComponentLastActiveTab,
browseFilters,
ref strBrowseLocations,
this.TargetFrameworkMoniker.FullName));
}
}
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
this.ShowProjectInSolutionPage = true;
}
return VSConstants.S_OK;
}