c# - asp.net代码显示编译器错误消息: CS1729: 'EmailReader.Pop3

运行以下代码时,我收到此错误消息:

错误信息:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS1729: 'EmailReader.Pop3Client' does not contain a constructor that takes 0 arguments

Source Error:
Line 148:        private static object @__fileDependencies; 
Line 149:  
Line 150:        [System.Diagnostics.DebuggerNonUserCodeAttribute()] 
Line 151:        public pop3client_aspx() { 
Line 152:            string[] dependencies;

Home.aspx.cs代码:
protected void Button1_Click(object sender, EventArgs e)
{
    Session["email"] = txt_email.Text;
    Session["pwd"] = txt_password.Text;
    Response.Redirect("Pop3Client.aspx");
} 

当我单步执行代码时,不会执行Pop3Client.aspx.cs page_load事件中的断点。任何想法如何解决这个问题?

Pop3Client.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{

    int page = 1;
    if (Request.QueryString["page"] == null)
    {
        Response.Redirect("Pop3Client.aspx?page=1");
        Response.Flush();
        Response.End();
    }
    else
        page = Convert.ToInt32(Request.QueryString["page"]);
    try
    {
        Email = Session["email"].ToString();
        Password = Session["pwd"].ToString();
    }
    catch (Exception ex)
    { 
        Response.Redirect("Home.aspx"); 
    }

    int totalEmails;

    List<Email> emails;
    string emailAddress;
    using (EmailReader.Pop3Client client = new EmailReader.Pop3Client(Host, Port, Email, Password, true))
    {
        emailAddress = client.Email;
        client.Connect();
        totalEmails = client.GetEmailCount();
        emails = client.FetchEmailList(((page - 1) * NoOfEmailsPerPage) + 1, NoOfEmailsPerPage);
    }

    int totalPages;
    int mod = totalEmails % NoOfEmailsPerPage;
    if (mod == 0)
        totalPages = totalEmails / NoOfEmailsPerPage;
    else
        totalPages = ((totalEmails - mod) / NoOfEmailsPerPage) + 1;
    for (int i = 0; i < emails.Count; i++)
    {
        Email email = emails[i];
        int emailId = ((page - 1) * NoOfEmailsPerPage) + i + 1;
        TableCell noCell = new TableCell();
        noCell.CssClass = "emails-table-cell";
        noCell.Text = Convert.ToString(emailId);
        TableCell fromCell = new TableCell();
        fromCell.CssClass = "emails-table-cell";
        fromCell.Text = email.From;
        TableCell subjectCell = new TableCell();
        subjectCell.CssClass = "emails-table-cell";
        subjectCell.Style["width"] = "300px";
        subjectCell.Text = String.Format(DisplayEmailLink, emailId, email.Subject);
        TableCell dateCell = new TableCell();
        dateCell.CssClass = "emails-table-cell";
        if (email.UtcDateTime != DateTime.MinValue)
            dateCell.Text = email.UtcDateTime.ToString();
        TableRow emailRow = new TableRow();
        emailRow.Cells.Add(noCell);
        emailRow.Cells.Add(fromCell);
        emailRow.Cells.Add(subjectCell);
        emailRow.Cells.Add(dateCell);
        EmailsTable.Rows.AddAt(2 + i, emailRow);
    }
    if (totalPages > 1)
    {
        if (page > 1)
            PreviousPageLiteral.Text = String.Format(SelfLink, page - 1, "Previous Page");
        if (page > 0 && page < totalPages)
            NextPageLiteral.Text = String.Format(SelfLink, page + 1, "Next Page");
    }
    EmailFromLiteral.Text = Convert.ToString(((page - 1) * NoOfEmailsPerPage) + 1);
    EmailToLiteral.Text = Convert.ToString(page * NoOfEmailsPerPage);
    EmailTotalLiteral.Text = Convert.ToString(totalEmails);
    EmailLiteral.Text = emailAddress;
}

最佳答案

您似乎已经在Pop3Client代码隐藏类中添加了带有参数的构造函数。这意味着您的类不再包含无参数的构造函数。 ASP.NET要求存在这样的构造函数,以便在首次加载页面时对其进行编译。

没有理由在ASP.NET页面的代码中没有构造函数,因此您应该将其删除,但是添加无参数构造函数也应该起作用。

关于c# - asp.net代码显示编译器错误消息: CS1729: 'EmailReader.Pop3Client' does not contain a constructor that takes 0 arguments,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13361387/

相关文章:

compiler-errors - 带有C++/CLI的VS2012中的错误C2039错误

compiler-errors - IPv4和IPv6地址的lex模式

compiler-errors - 我的部分产品生成器出了什么问题

compiler-errors - 免费的基本编译器错误23 : File not found, l

c# - 编译委托(delegate)和调度程序时出错

android - BadTokenException无法添加窗口(ProgressDialog)

wpf - WPF,将XAML文件移动到另一个项目

compiler-errors - 如何使Groovy Shell读取#符号

sorting - "nonL value in assignment "错误 C++对链表进行排序

qt - Qwt和Boost::signals