Hi All,
Why if I compile the following code with Target Framework as .NET Framework 4.0 I can install the .NET Framework 4.0 version of my custom control while if I compile it with Target Framework as .NET Framework 2.0 I can only install .NET Framework 2.0 version of my custom control.
I would like to use the same .NET Framework 2.0 utility to install both versions (Fx20 and Fx40) of my custom control. What should I change?
Thanks,
Alberto
/// <summary>
/// Performs an installation of toolbox items.
/// </summary>
private void Install(DTE visualStudio)
{
// Progress has occurred
OnProgressChanged();
// Locate the project template necessary to access the Toolbox
string tmpFile = Path.GetFileNameWithoutExtension(Path.GetTempFileName());
string tmpDir = string.Format("{0}{1}", Path.GetTempPath(), tmpFile);
Solution2 solution = visualStudio.Solution as Solution2;
string templatePath = solution.GetProjectTemplate(_ProjectTemplate, "CSharp");
// Progress has occurred
OnProgressChanged();
// Create a temporary project to get at the Toolbox for that platform
Project proj = solution.AddFromTemplate(templatePath, tmpDir, tmpFile, false);
// Progress has occurred
OnProgressChanged();
// Get a handle to the toolbox itself
EnvDTE.Window window = visualStudio.Windows.Item(EnvDTE.Constants.vsWindowKindToolbox);
EnvDTE.ToolBox toolbox = (EnvDTE.ToolBox)window.Object;
// Check to see if the Toolbox tab already exists
ToolBoxTab CurrentTab = null;
foreach (ToolBoxTab tab in toolbox.ToolBoxTabs)
{
// Is there a match?
if (tab.Name == _ToolboxTab)
{
// Yes.
CurrentTab = tab;
break;
}
}
// Is there an existing tab?
if (CurrentTab == null)
{
// No. Create a new one!
CurrentTab = toolbox.ToolBoxTabs.Add(_ToolboxTab);
}
// Progress has occurred
OnProgressChanged();
// Select the Toolbox tab
CurrentTab.Activate();
// And add the control to it
CurrentTab.ToolBoxItems.Add("MyUserControl", _AssemblyPath, vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent);
// Progress has occurred
OnProgressChanged();
}