【问题标题】:The name 'WebMail' does not exist in the current context当前上下文中不存在名称“WebMail”
【发布时间】:2013-03-05 06:37:47
【问题描述】:

以下代码在本地运行良好,但是当我将其发布到服务器时,我收到错误 The name 'WebMail' does not exist in the current context。不知道为什么会发生这种情况,特别是如果它在本地工作。感谢您的帮助。

public void SendMessage()
        {
            WebMail.SmtpServer = SmtpServer;
            WebMail.UserName = ServerUsername;
            WebMail.Password = ServerPassword;
            WebMail.From = this.From;
            var recipents = string.Join(",", this.To);
            WebMail.Send(recipents, this.Subject, this.Body);
        }

【问题讨论】:

  • WebMail 上按 F12 并准确查看它所在的命名空间和 DLL。确保在您的服务器上部署和/或 GAC'ed DLL。
  • System.Web.Helpers,因为它在 system.web 它应该在服务器上
  • 虽然问题不大,但请尝试将其显式添加到 web.config。我不记得触发问题的情况,但我已经看到服务器上代码中的代码抛出异常并在添加到 web.config 时开始工作的问题。 (可能不是问题,但可能值得检查。)
  • 我确保 添加了
  • 您是否在服务器上安装了 asp.net mvc 或至少安装了所需的 .dll,例如System.Web.Helpers.dllblog.discountasp.net/…

标签: c# asp.net-mvc


【解决方案1】:

谢谢。 VS 2012 中的发布没有添加 helper.dll。添加它,现在可以工作了!谢谢大家的建议。

【讨论】:

    猜你喜欢
    • 2013-10-02
    • 2014-04-22
    • 2017-06-17
    • 2015-09-11
    • 1970-01-01
    • 1970-01-01
    • 2022-12-18
    • 2020-11-02
    相关资源
    最近更新 更多