3

I have a C# Windows Forms project in which I use a component that I obtained through nuget. Now I was wondering what is the correct way of adding this component to the toolbox in the designer. Should I make a separate copy of the component on my hdd and add it from there or should I just add it from the project's packages folder or maybe do something different entirely?

I was wondering if:

  • having a separate copy of the component won't cause problems if I use a newer version of the component in another project?
  • using the copy from packages folder and then deleting, moving the project, won't that cause problems with the toolbox?
jahu
  • 5,427
  • 3
  • 37
  • 64
  • It is automatic, don't do anything. Verify the setting that ensures the controls are automatically added: Tools > Options > Windows Forms Designer > General > "Automatically Populate Toolbox" = True. – Hans Passant Mar 14 '15 at 13:27
  • @HansPassant Then something must be off with the component I'm using. It does not get automatically added to the ToolBox (yes I have the option set to true). Maybe it has something to do with the fact that the component is part of a bigger library and you don't have to use the component to use the library (or maybe the author of the nuget package has to do something for the component to be added to the toolbox and myabe he\she hasn't done that). The library in question is OpenCVSharp (https://github.com/shimat/opencvsharp). – jahu Mar 14 '15 at 13:46
  • OpenCV, *sigh*. It is very non-trivial dependencies that cannot be found at design time. – Hans Passant Mar 14 '15 at 13:52
  • @HansPassant So what you say is that because of the references to OpenCV (insert other non .Net dependences here) the component cannot be added automatically? – jahu Mar 14 '15 at 14:02
  • @HansPassant I just remembered not being able to use Awesomium component in the designer at all, but OpenCVSharp components can be added (and used there). So I'm not sure if non-trivial dependencies apply here. – jahu Mar 15 '15 at 11:54
  • @HansPassant I just tried with VS2017 and installed a couple of components and none of the showed up in the toolbox. "Automatically Populate Toolbox" is true... – Xan-Kun Clark-Davis Jun 08 '17 at 22:17
  • Please leave a comment here so that this issue gets visibility: https://github.com/NuGet/Home/issues/3509#issuecomment-337100601 – jnm2 Nov 25 '17 at 18:25
  • I have sunk half a week into a workaround you might find useful for the present: https://github.com/NuGet/Home/issues/3509#issuecomment-347621114 – jnm2 Nov 28 '17 at 18:39

1 Answers1

1

Based on the conversation I had with Hans Passant in the comments (since he didn't post it as an answer):

Normally, when you get a windows forms component from nuget, it will automatically get added to the designers toolbox. The only time when it should not happen is when "Automatically Populate Toolbox" is set to false (Tools > Options > Windows Forms Designer > General).

In my particular case this does not happen. It might be related to "non-trivial dependencies that cannot be found at design time". But I'm not entirely sold on that, because I remember not being able to use such components in the designer at all, however the component that lead me to asking this question can be used there just fine. However this is likely material for a different question (and possibly on a different site).

jahu
  • 5,427
  • 3
  • 37
  • 64