Microsoft KB Archive/322730

= BUG: &quot;Could not be loaded&quot; error occurs when you add a .NET UserControl control to a form =

Article ID: 322730

Article Last Modified on 2/17/2006

-

APPLIES TO


 * Microsoft Visual Studio .NET 2003 Professional Edition
 * Microsoft Visual Studio .NET 2003 Enterprise Architect
 * Microsoft Visual Studio .NET 2003 Enterprise Developer
 * Microsoft Visual Studio .NET 2003 Academic Edition
 * Microsoft Visual Studio .NET 2002 Professional Edition
 * Microsoft Visual Studio .NET 2002 Enterprise Architect
 * Microsoft Visual Studio .NET 2002 Enterprise Developer
 * 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 '. ' 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 &quot;Symptoms&quot; 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
&quot;Alias&quot; 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.



Steps to Reproduce the Behavior
 Create a new folder on the C drive, and then name the folder a#test . Follow these steps to create a new Windows Application project:  Start Microsoft Visual Studio .NET. On the File menu, point to New, and then click Project. Click either Visual Basic Projects or Visual C# Projects under Project Types, and then click Windows Application under Templates.</li></ol> </li> On the File menu, point to Add Project, and then click New Project to add a second project to the solution.</li> Follow these steps in the Add New Project dialog box: <ol style="list-style-type: lower-alpha;"> Click Browse.</li> Click the folder that you created in step 1, and then click OK.</li> Click either Visual Basic Projects or Visual C# Projects under Project Types, and then click Windows Control Library under Templates.</li></ol> </li> On the Build menu, click Build Solution to build the two projects.</li> Open Form1 in Design view.</li> Try to drag a UserControl control from the toolbox to the form. Notice that you receive the error message that is listed in the &quot;Symptoms&quot; section.</li></ol>

Keywords: kbbug kbnofix kbvs2002sp1sweep kbvs2005swept kbvs2005doesnotapply KB322730

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.