Visual Studio do not add my component (from a DLL)

2019-01-26 05:13发布

As stated in the title, I copied my DLL in Visual Studio project, set it to "content" and "copy always". Added a reference to this DLL and set it to "copy locally".

I successfully managed to instance my component to a form through code but it doesn't appear in the toolbox, really boring.

How can I solve this issue?

If I link directly the DLL project to this project it works, but now I'm treating the DLL as "external" so it's not part of the same solution of the DLL project.

7条回答
放荡不羁爱自由
2楼-- · 2019-01-26 05:38

I was having this same issue. I am working in Visual Studio 2010.

My user control library is written in C# and my project I'am importing it into is in Visual Basic.

If I had the C# project in my solution, the custom user controls would show up automatically. But if I only referenced the DLL it would not load the custom user controls from the referenced library into the "Toolbox".

The above post that mentions finding the file in explorer and dragging and dropping it into the toolbox solved the problem. This is a very strange way of behaving. VB user control libraries don't require this step.

This has been an issue I have had sitting on the burner for the last 2 years.

I would up-vote the previous answer but I don't have enough rep yet.

This post could use some better tags, cause it was buried on most of my google searches.

So

  1. Reference the user control library
  2. Drop the DLL file into the tool box.

One question I have in regards to this is: what happens if you change the project reference to the DLL (because it moved) and not attempt to update the toolbox reference (by removing the control from the toolbox and dragging and dropping the DLL from the new location)?

查看更多
相关推荐>>
3楼-- · 2019-01-26 05:41
  • Right-click in the toolbox.
  • Click "Choose Items..."
  • Click "Browse..."
  • Navigate to your DLL and click Open
  • Then click "Ok"

Your components should then show up

查看更多
不美不萌又怎样
4楼-- · 2019-01-26 05:41

Here is what I did.

After install the net 3.5 chart download from MSDN link, I manually copied the 3.5 chart dlls to my project and refer to them. Then, from the "choose item" of toolbox, browse to the dlls and add them into toolbox. Make sure the checkbox is checked for the "chart" in the "choose item" popup.

After these, the "chart" item in the toolbox should be available and enabled for .NET 3.5 project.

NOTE (I am using Visual Studio 2010. I think my solution should work for 2012.)

查看更多
冷血范
5楼-- · 2019-01-26 05:46

The way I found to make this working is:

  1. Add the dll, reference it
  2. Compile the project
  3. Save the solution and restart visual studio

And then controls show up in toolbox (not always working, I think is a sort of visual studio bug)

查看更多
女痞
6楼-- · 2019-01-26 05:50

I had this problem with @AndrewFinnell's solution:

There are no components in 'c:....\XXXX.dll' that can be placed on the toolbox.

So I solved with drag and drop:

  • open Windows explorer and navigate to the DLL
  • drag the DLL and drop it on Visual Studio in the Toolbox, exactly where you want your components to appear.

I also realized that some components may have compatibility issues with certain .NET Framework versions. For instance A Professional Calendar/Agenda View That You Will Use seems not to work with .NET 4.5, while it does with .NET 4.

查看更多
成全新的幸福
7楼-- · 2019-01-26 05:54

Like said above,

  1. I reference the DLL in the client project by: in Solution Explorer right click > Add Reference, at this time the custom control doesn't appear in the Toolbox.

  2. I save it and close the client project.

  3. I restart Visual Studio 2012 and reopen the client project. Now the custom control is in the Toolbox.

  4. I reopen the custom control project, make some modifications and compile.

  5. And the most important, all changes that I made in the DLL project automatically were updated in the client project without need to redo "Add Reference".

查看更多
登录 后发表回答