Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, February 28, 2019 2:34 PM
Hi,
I have a problem adding my own user control to the control toolbox. Here is what I did:
- created a separate project in the solution, designed the user control and built it. The access modifier of my class is "public" and it inherits from "UserControl"
- added the control as a project reference to another project in the solution
- rebuild the entire solution, restart Visual studio
Problem:
- the control does not show up in the toolbox. I also tried to add it manually via "Choose items", add ".Net Framework Components", then browsed to dll. I get a message saying "The file <filename> is not valid."
thanks in advance
Holger
All replies (19)
Tuesday, March 5, 2019 7:04 AM ✅Answered
Hi Holger,
Now I know your detailed situation. But I think it's hard to do that before we figure it out two points:
1. What does the display window mean? A new class developed by MVTec? I test with the C(User control small), and it contains a groupbox with several other controls. But I can't prove that work for a user control from third-party.
2. For user control dlls from third-party, I'm not sure if we can use them in this way. If the dll from third-party has some check-in to avoid being encapsulated, then i think we can't solve this issue.
As for the complex situation, I can't reproduce same scenario to check and trouble shoot. And i suggest you can create a new solution like mine to check if this way works for usual situation. And if my answer works for your simple new solution but not the solution with MVTex products, I think you should ask the product team at MVTec.website for further support. You need to confirm with them, if their product can be encapsulated into another control.
Sorry for this inconvenience and do hope you can understand.
Best Regards
Lance
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].
Wednesday, March 6, 2019 1:32 PM ✅Answered | 3 votes
After a couple of hours of trying and failing, here is what I found out:
VS 2017, V 15.5.6
Using the platform target "x64" will not work for user controls. If you use "x64", you can build it with no errors, and it appears in the toolbox, but it is not useable. If you drag it onto a form, you get the message
"Failed to load toolbox item 'whatsoever'. It will be removed from the toolbox".
This applies for every user control, even one which is empty.
If you then switch to "Any CPU", you can use it, even if the platform target of the parent project is "x64". BUT when you start adding references to the user control project, MAKE SURE those are all built to "Any CPU". As soon as you have a single one built to "x64", you will get the same 'clear' message again: "Failed to load..."
best regards
Holger
Friday, March 1, 2019 1:32 AM
Hello,
Not knowing the "file name", I would suggest giving it a name that starts with a letter, does not end in a number, has no spaces or odd characters in the name followed by trying again.
It would be helpful to know exactly what the file name is and which version of Visual Studio is being used.
More information is better than less information.
One more thing, did the user control appear properly in the toolbox after compiling the user control without attempting to add it to the toolbox yourself?
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
VB Forums - moderator
Friday, March 1, 2019 4:49 AM
Hi friend,
Welcome to MSDN forum.
I totally understand what you mean. But the point is what the kind of your user control and application? Winform app and winform user control or wpf app and wpf user control.
It could be better if you share more details about them.
Also, as i know in VS2015 and later versions we have an much easier way to add user control to ToolBox. You can give it a try like below:
Scenario: A project(winform app) and B Project(WindowsFormsControlLibrary) both in a solution.
Design the user control and build the project successfully. Go B project=>properties=>open folder in file explorer and find the output MyButtonControl.dll. Simply drag the dll to ToolBox menu you can find the user control have been loaded succeddfully. (Focus on the .cs[designer] file to display other controls, and make the ToolBox always display like red point)
Also, check the Tools > Options > Windows Forms Designer > General : AutoToolboxPopulate, make sure set it "Ture".
Hope it works. Any update or feedback please feel free to contact us.
Best Regards
Lance
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].
Friday, March 1, 2019 8:35 AM
Hi Karen,
the <filename> was intended as a placeholder. The complete name reads
"D:\share\SDK\Vanguard\bin\Vanguard.UCImageDisplay.dll"
I was already suspecting that the dot was causing trouble, and changed the filename accordingly, but to no avail.
best regards
Holger
Friday, March 1, 2019 8:56 AM
Hi Lance,
here are the details: I use VS 2017 Professional, User control and application are both WinForms.
thanks for the hint concerning AutoToolboxPopulate. This brings me one step further:
The control now shows up in the toolbox immediately after rebuilding. But if I drag it onto a form, I get the message
"Failed to load toolbox item 'ucImageDisplay'. It will be removed from the toolbox".
I suspect that there is a problem with the references that I use within the control, like log4net, etc. To make things even more complicated, my user control contains an element which itself is a usercontrol and has references. Perhaps these references cannot be resolved properly at design time. Is there any way to inspect the dependencies of the control?
best regards
Holger
Friday, March 1, 2019 9:21 AM
Hi Holger,
Glad to know you can show the control in toolbox now. I'm not sure about if dependence can affect that issue. But as you mentioned above, I suggest you can create a simple demo to check for it.
1.Create a simple WindowsFormsControlLibrary and add several button control into it. Build the project and drag the dll to ToolBox. If that issue didn't occur, then maybe "Failed to load toolbox item 'ucImageDisplay'. It will be removed from the toolbox" result from the dependence.
In addition: Maybe you can get some help from this similar issue.
Best Regarsd
Lance
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].
Monday, March 4, 2019 2:59 AM
Hi Holger,
Sorry to trouble you and just want to confirm that your issue is solved or not, if not, please feel free to let us know, we will try our best to help you out.
BTW, if you think the reply is helpful and could please mark it as answer, that benefits for other community members who meet the similar issue, thanks in advance.
If you have any other VS IDE issues, please let us know.
Have a nice day!
Best Regards
Lance
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].
Monday, March 4, 2019 9:24 AM
Hi Lance,
the issue is not solved yet. I can add a user control as you described above in your post, as long as it contains only buttons etc.
I went through the items in the stackoverflow link that you posted, and tried several things including changing processor architecture.
Therefore, I would appreciate to have an analysis tool in VS similar to the good old dependency walker to inspect all the dependencies and references. Also I'm wondering if there is any error output that I'm not aware of, like a log file for designer errors etc.
best regards
Holger
Monday, March 4, 2019 11:05 AM
Hi friend,
Thank you for your feedback. I feel something confused about it. Do you mean you have a user controlA, this controlA has added reference to controlB meanwhile controlB has added reference log4net?
I have three projects in a solution. A(winform) B(User control big) C(User control small)
1.C add reference to log4net and use it in button-click event.
2.B add reference to C and add it as part of it.
3.Rebuild the solution and add the B.dll to toolbox successfully.
4.Now in A, I successfully use the B from toolbox.
Not sure if my situation is similar to yours. You can share more details here and i will reply you as far as i can tomorrow.
Best Regards
Lance
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].
Monday, March 4, 2019 11:32 AM
Hi Lance,
I have a user control from a third party supplier (MVTec). It implements a display window for several image types. Lets call this control UCExt. UCExt needs a reference which is also provided by the third party supplier, lets call it RefExt.
Now I create a new project within my solution and start designing a new user control which, along other WinForms controls, contains an instance of UCExt. Therefore I of course have to add the reference RefExt to the project. This new project builds without any problems but I cannot use the control (as described above).
When I use UCExt and RefExt as an ordinary usercontrol in my solution, I do not have any problems. The problems arise when I try to encapsulate UCExt into my own usercontrol.
best regards
Holger
Tuesday, March 5, 2019 9:29 AM
Hi Lance,
ok, I will contact the suppliers support.
VS2017 showed a weak point here, because it did not provide any means for error analysis but the messages "file is not valid" and "failed to load control".
Thank you for your help and best regards
Holger
Tuesday, March 5, 2019 9:32 AM
Hi friend,
Thank you for your feedback. And sorry for this inconvenience.
Have a nice day!
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].
Thursday, March 7, 2019 3:35 AM
Hi friend,
Thanks for sharing your solution. I do use 'anycpu' in every project. Maybe that's why i can't reproduce same issue. And you can mark it as answer so that more members can benefit.
Thanks.
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].
Wednesday, June 5, 2019 5:40 PM
Has this x64 compiler problem been fixed in VS 2019 Professional ??
Thanks
Wednesday, June 5, 2019 5:41 PM
Hi...
ALL of my projects are compiled for x64 platforms... and I am not adding an "anycpu" configuration.
Has this issue been fixed for VS 2019 Professional Edition ?
Thanks
Wednesday, June 5, 2019 5:43 PM
Does this also work for controls built ONLY with an x64 platform ( NOT anycpu ) ??
Thanks
Wednesday, June 5, 2019 5:44 PM
I think this is due to the x64 compiler option... not references???
Is the x64 usercontrol issue fixed in VS 2019 professional ?
Thanks
Wednesday, June 5, 2019 5:45 PM
Did you remove the AnyCpu compiler option and use only x64 ??
Is this fixed in VS 2019 professional ?
Thanks