locked
Parser Error - Could not load type 'mail'. RRS feed

  • Question

  • User651828378 posted

    Hi i get this error

    .:Error:.
    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: Could not load type 'mail'.

    Source Error:


    Line 1:  <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="mail.aspx.vb" Inherits="mail" %>
    Line 2: 
    Line 3:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ (...)


    Source File: /mail.aspx    Line: 1

    .:mail.aspx:.

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="mail.aspx.vb" Inherits="mail" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ (...)
    
    <html xmlns="http://www.w3.org/ (...)
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <h1>send mail</h1>
        <p><asp:TextBox runat="server" ID="fname" />Di fornavn</p>
        <p><asp:TextBox runat="server" ID="lname" />Dit efternavn</p>
        <p><asp:TextBox runat="server" ID="email" />Din mail</p>
        <p><asp:TextBox runat="server" ID="subject" />om</p>
        <p><asp:TextBox runat="server" ID="message" />tekst</p>
        <asp:Button runat="server" ID="Button1" Text="Send Mail" />
        <br />
    
        <asp:Label runat="server" ID="lblEmail" />
        </div>
        </form>
    </body>
    </html>

    .:mail.aspx.vb:.

    Imports System.Web.Mail
    Imports System.Text
    
    Public Class mail
        Inherits System.Web.UI.Page
    
        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim Body As String = "From: " + fname.Text + " " + lname.Text + Environment.NewLine + "Email: " + email.Text + Environment.NewLine + Environment.NewLine + "Message: " + Environment.NewLine + MailMessage.Text
    
            Dim MM As New System.Net.Mail.SmtpClient
            MM.EnableSsl = False
            MM.Host = "asmtp.unoeuro.com"
            Dim cred As New System.Net.NetworkCredential("mitbrugernavn", "minkode")
            MM.Credentials = cred
            MM.Send(email.Text, "min mail", subject.Text, Body)
            ClearFields()
            lblEmail.forecolor = Drawing.Color.Green
            lblEmail.Text = "Mail blev sendt"
            lblEmail.Visible = True
        End Sub
    
        Protected Sub ClearFields()
            fname.Text = ""
            lname.Text = ""
            email.Text = ""
            subject.Text = ""
            message.Text = ""
        End Sub
    
    End Class 



    Wednesday, April 13, 2011 6:12 AM

Answers

  • User651828378 posted

    Hi

    After starting a new project in VS2010, with no files in it and copy/past the code to new added sites then it worked.
    maybe there was some errors in the other project.

    But thx for replyes

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 2, 2011 8:46 AM

All replies

  • User371383779 posted

    Your code looks right as this error should not have come. But verify following things that might solve your problem probably.

    • Check if your mail class is contained in a namespace or not. If yes then you will have to fully qualify the class name in inherits attribute of Page tag like inherits="MyNamesapce.mail".
    • Check if you mail.aspx.vb class is excluded from the project or not. If this is excluded from the project/solution then right click on it and then selected "Include In Project".

    Public Namespace MyNamespace
        Public Class mail
    
    
    
    .........
    
    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="mail.aspx.vb" Inherits="MyNamespace.mail" %>

     

    Wednesday, April 13, 2011 7:00 AM
  • User651828378 posted

    Hi

    Thx for response.

    I have looked at the code, and now 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 'MyNamespace.mail'.

    Source Error:

    Line 1:  <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="mail.aspx.vb" Inherits="MyNamespace.mail" %>
    Line 2:  
    Line 3:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


    Source File: /mail.aspx    Line: 1

    Wednesday, April 13, 2011 2:04 PM
  • User42903263 posted

    You might want to look over all the solutions at

    http://forums.aspfree.com/net-development-11/parser-error-message-could-not-load-type-17894.html

    and see if any of them work for you.

    HTH,

    Andrew

    Friday, April 22, 2011 12:38 PM
  • User651828378 posted

    Hi

    After starting a new project in VS2010, with no files in it and copy/past the code to new added sites then it worked.
    maybe there was some errors in the other project.

    But thx for replyes

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 2, 2011 8:46 AM