Using ParseControl to load ASCX files stored as EmbeddedResource, I found that tilde paths (“~” denoting app root) were not interpreted to mean application root, but were left unchanged in markup attributes.
The solution is to set the AppRelativeTemplateSourceDirectory member variable of the loading control:
Control userControl = page.ParseControl(content); this.AppRelativeTemplateSourceDirectory = userControl.AppRelativeTemplateSourceDirectory; this.Controls.Add(userControl);
Pingback: Series: ASP.Net User Control Libraries « devioblog