Visual Studio 2022 Visual Basic Error in Loading a UserControl in another UserControl

Novum Robotics & Automation 1 Reputation point
2022-04-25T14:30:45.117+00:00

I have a solution with several projects in visual basic.
I made it in visual studio 2019 community and now I try to continue developping it in visal studio 2022 community.

When I run my solution in Debug mode in visual studio 2022, then it works fine.

However when I try to open an user control 'UserControl_A', which I have defined, and this user control 'UserControl_A' contains another user control, say 'UserControl_B', then I get a designer error.
So I removed the user control 'UserControl_B' from 'UserControl_A.designer.vb'.

Then I opened the designer of 'UserControl_A'.

Next I get user control 'UserControl_B' from the ToolBox and put it at the correct place in UserControl_A, and then I get the following error:
Failed to create component 'UserControl_B'. The error message follows: 'system.IO.FileNotFoundException: Could not load file or assembly 'name of assembly in my solution'

UserControl_B uses objects from 'name of assembly in my solution'
UserControl_A and UserControl_B are in the same project. When I open UserControl_B in Design mode, then it opens correctly, no error.

So when running the program then this 'assembly in my solution' can be found by visual studio, but when I try to put UserControl_B in UserControl_A it fails to do so.

Can anyone help me, how to fix this?
Thanks.

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,579 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Jiachen Li-MSFT 26,671 Reputation points Microsoft Vendor
    2022-04-26T06:37:43.413+00:00

    Hi @Novum Robotics & Automation ,

    Make sure you don't check debug folder and the output mode is release.
    In case of debug mode, the .net looking for required dlls in bin/debug folder but the output mode is release and these ddls will be copied to bin/release folder. So you have to copy ddls into bin/debug folder.

    From "Unable to create component" error
    Best Regards.
    Jiachen Li


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Novum Robotics & Automation 1 Reputation point
    2022-04-29T05:11:49.897+00:00

    I have checked in some other projects of mine, and the Problem of a UserContorl in a UserControl exists there to.

    So, I very much hope that the problem will be fixed in Visual Studio 2022.
    I