User Controls not showing up in the toolbox

前端 未结 29 2158
暗喜
暗喜 2020-12-13 12:21

I have some UserControls that I created in ProjectA. I have ProjectB that has a windows form that I want to put the controls on. Both of these projects are in a single sol

相关标签:
29条回答
  • 2020-12-13 12:25

    Check project path, avoid & , # etc.

    I've moved my solution from drive:\work\c#\folder\ to drive:\work\folder and it solved the problem.

    0 讨论(0)
  • 2020-12-13 12:27

    I fell into this trap just a couple of hours ago.
    I've got a .NET 2.0 Windows Application project with some custom UserControls; it worked fine. So I decided to order my files in subfolders, to make my project a little bit cleaner.
    After that, Visual Studio 2010 designer stopped loading my forms, and ToolBox won't show my controls anymore.
    I freaked out, moving back source files in project root, resetting ToolBox, but nothing seemed to work. After that, I remembered I used ReSharper "Remove Unused References", so I tried to put back unused reference, in particular System.Data: problem solved! :O I can't say you why, but this worked for me.
    Hope my experience can help someone else. :)
    Bye, Nando

    0 讨论(0)
  • 2020-12-13 12:29

    I was trying to build a x64 only application, so my platform target was set to x64 of course.

    However, even in 2016, Visual Studio (devenv.exe) is still a 32 bit process and it cannot load 64 bit assemblies. To check the bitness of your Visual Studio, open Task Manager and check for *32 at the name of the process.

    Workaround to see the Controls in the toolbox: set the platform target to Any CPU in the project settings. Do that for Debug and Release build, if necessary.

    0 讨论(0)
  • 2020-12-13 12:31

    Another reason that user controls may not show up in the toolbox is if they do not have a default constructor.

    0 讨论(0)
  • 2020-12-13 12:31

    It is possible for all of the above to fail.

    I fixed it by creating a new user control (TestControl) and it triggered Visual Studio to magically add my project's controls tab + controls back into the Toolbox. Then I just deleted the test control.

    This happened to me after recently installing a VS 2008 automated windows update, by the way.

    0 讨论(0)
  • 2020-12-13 12:34

    If you've tried following all the other answers and it still doesn't work, the following fixed it for me:

    • Right click on your project containing your control.
    • Select Properties.
    • In the Build settings category, make sure Register for COM interop is checked.
    0 讨论(0)
提交回复
热议问题