Appending the ToolboxItem.DependentAssemblies property
-
I am writing a Visual Studio 2008 Tool Window plugin that exposes a custom toolbox. I create controls on Forms using the 'ToolboxItem' class. I would like to append to the ToolboxItem dependencies, such that my assembly will be auto-inserted as a reference after the control creation. Here's an example of what I'm trying to do: ToolboxItem tbi = new ToolboxItem(typeof(CheckBox)); AssemblyName[] depends = tbi.DependentAssemblies; List listDepends = new List(); listDepends.AddRange(depends); listDepends.Add(new AssemblyName("MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e7d025b3483b4afc")); tbi.DependentAssemblies = listDepends.ToArray(); The control gets created fine, but 'MyAssembly' is not added to the project references. 'MyAssembly' is installed in the GAC - I've double checked that the full path is correct. Thanks, Aaron
-
I am writing a Visual Studio 2008 Tool Window plugin that exposes a custom toolbox. I create controls on Forms using the 'ToolboxItem' class. I would like to append to the ToolboxItem dependencies, such that my assembly will be auto-inserted as a reference after the control creation. Here's an example of what I'm trying to do: ToolboxItem tbi = new ToolboxItem(typeof(CheckBox)); AssemblyName[] depends = tbi.DependentAssemblies; List listDepends = new List(); listDepends.AddRange(depends); listDepends.Add(new AssemblyName("MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e7d025b3483b4afc")); tbi.DependentAssemblies = listDepends.ToArray(); The control gets created fine, but 'MyAssembly' is not added to the project references. 'MyAssembly' is installed in the GAC - I've double checked that the full path is correct. Thanks, Aaron
AFAIK, this isn't possible. Imagine what would happen if a malicious application injected itself as a dependency into the Form class. Load Form class = load malicious application into memory = bad in one way or another The best thing you could do would be making a derived class, and add your assembly as a reference