Asked by:
Parser error: could not load type......

Question
-
User-1793215261 posted
Hello
I have now managed to install the following NuGet packages the absence of which may have been causing a problem with the Salt/Hash code I have:
"Microsoft.AspNet.Providers.LocalDB" version="2.0.0"
"System.Web.Helpers.Crypto" version="3.2.3"
"WebHelpers" version="4.0.2"
"MarkdownSharp" version="1.13.0.0"The name of my Default project in the Package Manager Console is that of my project in Solution Explorer as, I understand, it should be.
When I click to load the page in my browser, I get a parser error: Parser Error: Could not load type 'Dima.Index'.
The error refers to this line at the top of my home page:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="index.aspx.vb" Inherits="Dima.Index" %>
This is a line VS 2017 has inserted, not me, at the top of my page. My index.aspx.vb file, has this at the top:
Partial Class index Inherits System.Web.UI.Page
My other pages, such as register.aspx has this:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="register.aspx.vb" Inherits="Dima.register" %>
and this at the top of register.aspx.vb:
Partial Class register Inherits System.Web.UI.Page
('register is green underlined because VS tells me I need a capital R).
How should this line
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="index.aspx.vb" Inherits="Dima.Index" %>
read, please?
Monday, December 17, 2018 10:30 PM
All replies
-
User475983607 posted
I would be a lot easier to help if you publish the project/solution on GIT. The problem could be a namespace issue but there is not way to verify. At least the the error message points to a namespace bug.
Monday, December 17, 2018 11:50 PM -
User-893317190 posted
Hi Bluenose,
I find your code
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="index.aspx.vb" Inherits="Dima.Index" %>
and
Partial Class index Inherits System.Web.UI.Page
Inherits="Dima.Index" means your aspx page inherits from a class named Dima.Index and vs could find the class.
Please pay attention your class index's first letter is lowercase and the first letter of Index in your Inherits="Dima.Index" is capitalized。
I think this is why you get the error.Please change one of them.
Best regards,
Ackerly Xu
Tuesday, December 18, 2018 1:25 AM -
User-1793215261 posted
Hello Ackerly Zu
Thanks for your reply.
I now have this in my aspx file:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="register.aspx.vb" Inherits="Dima.Register" %>
and this in my aspx.vb file:
Partial Class Register 'Public Classs register? Inherits System.Web.UI.Page
This is the error I am getting: Parser Error Message: Could not load type 'Dima.Register'.
Likewise, I have this in my home page (index.aspx):
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="index.aspx.vb" Inherits="Dima.Index" %>
and this in my index.aspx.vb file:
Partial Class Index Inherits System.Web.UI.Page
When I load index.aspx in my browser, I get: Parser Error Message: Could not load type 'Dima.Index'.
Thanks again for any advice.
Tuesday, December 18, 2018 1:47 PM -
User-1793215261 posted
I have put the 2 files register.aspx and register.aspx.vb here: https://github.com/Blue1992/dima
Thanks
Tuesday, December 18, 2018 1:55 PM -
User-893317190 posted
Hi Bluenose,
As you have commented in your register.cs ,you should change your partial class to Public class.
Public Class Register 'Public Classs register? Inherits System.Web.UI.Page
Best regards,
Ackerly Xu
Wednesday, December 19, 2018 1:23 AM -
User-1793215261 posted
In my index.aspx page, I now have
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="index.aspx.vb" Inherits="Dima.Index" %>
and, in my register.aspx file, I have
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="register.aspx.vb" Inherits="Dima.Register" %>
In my index.aspx.vb file, I have:
Public Class Index Inherits Page
and in my register.aspx.vb file, I have
Public Class Register Inherits Page
When I load index.aspx in my browser, I get: Parser Error Message: Could not load type 'Dima.Index'.
%@ Page Language="vb" AutoEventWireup="false" CodeBehind="index.aspx.vb" Inherits="Dima.Index" %>
and when I load register.aspx in my browser, I get: Parser Error Message: Could not load type 'Dima.Register'.
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="register.aspx.vb" Inherits="Dima.Register" %>
What else may be wrong?
Thank you.
Wednesday, December 19, 2018 9:07 AM -
User475983607 posted
For the second time, this error generally means there is a namespace mismatch between the page directive and the code behind. I can reproduce this issue by changing the page directive...
<%@ Page Title="About" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="About.aspx.cs" Inherits="WebFormsApp.bout" %>
so it does not match the Page class. Case matters!
namespace WebFormsApp { public partial class About : Page
The full error message is...
Server Error in '/' Application.
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: 'WebFormsApp.about' is not allowed here because it does not extend class 'System.Web.UI.Page'.
Source Error:
Line 1: <%@ Page Title="About" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="About.aspx.cs" Inherits="WebFormsApp.about" %> Line 2: Line 3: <asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
Source File: /About.aspx Line: 1Publish the solution on GIT if you need help fixing the project.
Wednesday, December 19, 2018 12:31 PM -
User-1793215261 posted
I can't see any mismatch: In my Register.aspx file, I have:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Register.aspx.vb" Inherits="Dima.Register" %>
and in Register.aspx.vb, I have at the top:
Imports System.Data.OleDb Public Class Register Inherits Page
VS tells me (light-bulb) that no other 'imports' and necessary.
In my Index.aspx file, I have
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Index.aspx.vb" Inherits="Dima.Index" %>
There are no imports for Index.aspx vecause VS tells me (light-bulb) that none is necessary, so I only have at the top:
Public Class Index Inherits Page
Where is the mismatch, please? Maybe I am staring at a glaring error.
Wednesday, December 19, 2018 1:01 PM -
User475983607 posted
There is just not enough information. I can only guess that you've copied the files from another project and the current project has a different assembly and root namespace.
You'll need to publish the entire solution if you want someone to fix the solution.
Wednesday, December 19, 2018 1:22 PM -
User-1793215261 posted
Hello mgebhard
This should be the whole project: https://github.com/SteveHigh/Dima
Thanks
Wednesday, December 19, 2018 3:52 PM -
User-893317190 posted
Hi Bluenose,
I have downloaded your project and try to start your project.
But I find an error : couldn't launch the iis express. So I remove the .vs file of your project(It will be rebuilded by visual studio) and change the port of the project
And I find another error in ViewSwitcher.ascx,so I download Imports Microsoft.AspNet.FriendlyUrls using nuget.
Finally , I opened the project and couldn't find you error: coundn't not load type.
I run it in visual studio 2017.
Best regards,
Ackerly Xu
Friday, December 21, 2018 8:11 AM