BUG: "Could not be loaded" error occurs when you add a .NET UserControl control to a form (322730)



The information in this article applies to:

  • Microsoft Visual Studio .NET (2003), Professional Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2003), Academic Edition
  • Microsoft Visual Studio .NET (2002), Professional Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2002), Academic Edition

This article was previously published under Q322730

SYMPTOMS

When you try to add an instance of a .NET UserControl control to a form, you may receive the following error message:
The user control 'WindowsControlLibrary1.UserControl1' could not be loaded. Ensure that the library containing the control has been built and a project reference has been made to the library containing the control. If you have changed the name of the user control, close and re-open the control's designer to update the toolbox item.

CAUSE

This error may occur because of the reasons that are stated in the error message. However, this error may also occur if the path to the location from which the UserControl project was opened contains a number sign (#). For example, you receive the error message that is listed in the "Symptoms" section if the path for the UserControl project is C:\My Documents\VC#.

RESOLUTION

Use one of the following three methods to resolve this problem.

Method 1

Rename the folder or the folders that contain the number sign (#).

Method 2

"Alias" the folder by sharing it, and then give the share a name that does not contain a number sign (#).

For example, if your computer name is MyComputer, and if the project is located in the C:\My Documents\VC# folder, create a network share for this folder, and then name the share VCSharp. Open the project from the \\MyComputer\VCSharp share instead of the C:\My Documents\VC# folder.

Method 3

If the UserControl project does not have to be loaded as part of the current solution, remove the project from the solution, and then reference the compiled user control DLL directly.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create a new folder on the C drive, and then name the folder a#test.
  2. Follow these steps to create a new Windows Application project:
    1. Start Microsoft Visual Studio .NET.
    2. On the File menu, point to New, and then click Project.
    3. Click either Visual Basic Projects or Visual C# Projects under Project Types, and then click Windows Application under Templates.
  3. On the File menu, point to Add Project, and then click New Project to add a second project to the solution.
  4. Follow these steps in the Add New Project dialog box:
    1. Click Browse.
    2. Click the folder that you created in step 1, and then click OK.
    3. Click either Visual Basic Projects or Visual C# Projects under Project Types, and then click Windows Control Library under Templates.
  5. On the Build menu, click Build Solution to build the two projects.
  6. Open Form1 in Design view.
  7. Try to drag a UserControl control from the toolbox to the form. Notice that you receive the error message that is listed in the "Symptoms" section.

Modification Type:MinorLast Reviewed:2/17/2006
Keywords:kbvs2005swept kbvs2005doesnotapply kbvs2002sp1sweep kbbug kbnofix KB322730