ASP.NET pages inheriting from template class

J

Jonathan Tower

I created a template class that inherits from the System.Web.UI.Page
class. The template class overrides the Render method and adds simple
HTML to the beginning and end of the page. I've then inherited the
template class in the codebehinds of my pages. This worked fine until
I moved the template class into a separate assembly. Now I'm getting
the following error on the page directive line of my aspx file:

Parser Error
Description: An error occurred during the parsing of a resource
required to service this request. Please review the following specific
parse error details and modify your source file appropriately.

Parser Error Message: Could not load type
'WebApplicationName.PageClassName'.


Here's the code:

--Tempate.vb-------------------------------------
Public Class Template
Inherits System.Web.UI.Page

Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
writer.Write("<HTML>")
MyBase.Render(writer)
writer.Write("</HTML>")
End Sub
End Class

--PageClassName.aspx---------------------------------
Public Class PageClassName
Inherits Template
....
End Class

--PageClassName.aspx.vb---------------------------------
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="PageClassName.aspx.vb"
Inherits="WebApplicationName.PageClassName"%>
....


The only difference between when it was working and not working is
that I moved the Template class into a separate assembly. Other
classes in the separate assembly are working fine. Any help would be
appreciated.
 
J

Jonathan Tower

Sorry, I should have mentioned that the assembly is in the GAC and
other classes in that assembly are working fine. What else could be
wrong?
 
J

Jonathan Tower

I've rechecked in the GAC and the new version of my assembly is
registered there. In the VS.NET IDE, the new template class shows up
in intellisense, so I'm guessing that the ASP.NET project is able to
see the new class just fine. For some reason, the parser is
complaining about the page directive inheriting from the codebehind
class.
 
J

J. Tower

I was able to solve this problem, but I'd love it if someone could explain
why this works and if there are any other work-arounds.

I realized that the separate assembly in the GAC where I was putting the
page template class was in a different namespace than the asp.net web
application. I took just the page template class out of the different
namespace leaving it in the root namespace (same as the web application).
After that, it worked. What's up with that? Where does this limitation
come from? Is this security related or something else?

I'd appreciate any help. Thanks...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top