We’re using LoadControl to load an ascx file into a placeholder control dynamically. The codebehind looks very simple:
child = base.LoadControl(manufacturerTemplate.TemplatePath);
this.ManufacturerPlaceHolder.Controls.Add(child);
The control header looks like this:
<%@ Control Language="C#" AutoEventWireup="true" Inherits="MyNamespace.MyControl" CodeBehind="MyControl.ascx.cs" %>
I’ve verified spelling of everything and compilation. It works fine in the ASP.NET Development web server. But when I upload it to our IIS host, I recieve this error:
Parser Error: Could not load type ‘MyNamespace.MyControl.
The codebehind compiles without errors. It’s actually a duplication of another control’s codebehind. (verified that the spelling is accurate) One of the things I’ve tried is to modify the @Control directive to point to the 2nd control’s codebehind (sharing the same functionality)….it works perfectly.
Some of the other things I’ve tried:
- File System Permissions
- Restarting IIS
- Clearing the ASP.NET Temp folder
So at this point, I’ve no idea why I can’t use the codebehind that I’m attempting to add will not work. I can point it to the other class’s codebehind, and it works fine. (after changing the “inherits” value) So I can only suppose that it is a compilation problem. But it builds correctly without errors.
What am I forgetting?
I found the problem. The project was a “Web Application” instead of a “Web Site. So it had to not only be compiled, but I had to deploy the website’s assembly.