"FileNotFoundException" Error Message When You Use Page.LoadControl to Load a Web User Control (823266)



The information in this article applies to:

  • Microsoft Windows SharePoint Services

SYMPTOMS

When you try to use the Page.LoadControl method to load a Web user control (.ascx file) in a Web Part of a Microsoft Windows SharePoint Services Web page, you may receive the following error message:
FileNotFoundException

The file could not be found.
C:\Inetpub\Wwwroot\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\Template\1033\STS\filename.ascx

CAUSE

This problem may occur if you use a relative path in the Page.LoadControl method to load a Web user control, as in the following example:

Dim myControl As MyControl = CType(Page.LoadControl("MyControl.ascx"), MyControl)

WORKAROUND

To work around this behavior, specify an absolute path when you use the Page.LoadControl method, as in the following example:
Dim myControl As MyControl = CType(Page.LoadControl("/MyControl.ascx"), MyControl)

STATUS

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

MORE INFORMATION

For more information, visit the following Microsoft Web site:

Modification Type:MinorLast Reviewed:7/27/2006
Keywords:kbprb KB823266 kbAudITPRO