Parser Error Message: Could not load type

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • OuTCasT
    Contributor
    • Jan 2008
    • 374

    #1

    Parser Error Message: Could not load type

    Ive created a new page in my website project.
    Now I have used a master page as follows
    Code:
    <%@ Page MasterPageFile="[ProjectName].master" %>
    To use codebehind i have added this to the string

    Code:
    <%@ Page MasterPageFile="[ProjectName].master" CodeBehind="registerbusiness.aspx.vb" Inherits="[ProjectName].registerbusiness" %>
    When i run the project i get this error:

    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 '[ProjectName].registerbusine ss'.
    Could you inform me why I would be getting this error.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Just so you know, what you have as [ProjectName] is actually the Project's Namespace. By default the namespace for the project is the same name as the project; however this can be changed, so the ProjectName does not always match the Project's Namespace.

    Anyways, your @Page directive should look something like:

    Code:
    <%@ Page MasterPageFile="[relative path to the master page]"
                      CodeBehind="registerbusiness.aspx.vb"
                      Inherits="[ProjectNamespace].registerbusiness"
                      Language="vb"
    %>
    When you look at code implementation found in your registerbusines s.aspx.vb you should see the a Partial Class with the same name as specified in your @Page directive's Inherit attribute. If this name is different then it won't work. If the partial class is in a different namespace, then it won't work either.

    Here's an example of the @Page directive for a page that uses a MasterPage (located in the root of the project) from my project:

    Code:
    <%@ Page MasterPageFile="~/MasterPage.master"
                      CodeBehind="Default.aspx.vb"
                      Inherits="TestProject.Default"
                      Language="vb"
    %>
    And the VB.NET code in the Default.aspx.vb file looks like:
    Code:
    Partial Public Class Default
        Inherits System.Web.UI.Page
    '......
    '......
    End Class
    The default namespace (for the project) is automatically applied to the Default partial class.

    -Frinny

    Comment

    • OuTCasT
      Contributor
      • Jan 2008
      • 374

      #3
      Here is my masters page
      Code:
      <%@ Master Language="VB" AutoEventWireup="false" CodeBehind="CreativeHearts.master.vb" Inherits="Creative_Hearts_2._0.CreativeHearts" %>
      And here is my code for my RegisterBusines sLogin.aspx page
      Code:
      <%@ Page MasterPageFile="Creativehearts.master" CodeBehind="registerbusinessLogin.aspx.vb" Inherits="Creative_Hearts_2._0.registerbusinesslogin" %>

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        It sounds like you haven't done a lot of work on the page that's using the master page yet.

        Try adding a new page that uses master the master page:
        • Right click on the solution in the solution browser
        • Click on Add -> New Item
        • Choose Web Content Form and give it a name
        • Click the Add button
        • Click the Master Page that you want the new web/content form use
        • And click OK



        This will give you a page that should work properly.

        Comment

        • OuTCasT
          Contributor
          • Jan 2008
          • 374

          #5
          I think that somewhere along the line i accidently renamed the project and then renamed it back again. Because when I add a fresh webform and i dont reference my master page then i get the same error message.

          I just redone the project.

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            Oh this is a website not a web application.
            Try removing the Namespace from the page directive...see if that helps?

            Comment

            Working...