C# 类型或命名空间名称';Hangfire&x27;找不到(是否缺少using指令或程序集引用?)

C# 类型或命名空间名称';Hangfire&x27;找不到(是否缺少using指令或程序集引用?),c#,razor,C#,Razor,下面是关于Hangfire.io的教程: 但是,当我复制并粘贴提供的~/Views/Emails/NewComment.cshtml代码时: @model Hangfire.Mailer.Models.NewCommentEmail To: @Model.To From: mailer@example.com Subject: New comment posted Hello, There is a new comment from @Model.UserName: @Model.Comm

下面是关于Hangfire.io的教程:

但是,当我复制并粘贴提供的~/Views/Emails/NewComment.cshtml代码时:

@model Hangfire.Mailer.Models.NewCommentEmail

To: @Model.To
From: mailer@example.com
Subject: New comment posted

Hello,
There is a new comment from @Model.UserName:

@Model.Comment

<3
型号/NewCommentEmail.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Postal;

namespace HangFire.Mailer.Models
{
    public class NewCommentEmail : Email
    {

        public string To { get; set; }
        public string UserName { get; set; }
        public string Comment { get; set; }
    }
}
似乎当我创建几乎任何其他类型的视图时:在视图/电子邮件中:“MVC 5视图页面(Razor)、MVC 5视图页面布局(Razor)…”,页面显示当前上下文中找不到的所有以“@”开头的元素。 项目Soln名称为“Hangfire.Mailer”。

首先,(首先,您需要)安装Postal NuGet包,以便能够使用该类

资料来源:

安装包:

C#区分大小写,因此您应该使用Hangfire或Hangfire

现在在定义中使用大写字母:

namespace HangFire.Mailer.Models
但引用中使用小写字母:

@model Hangfire.Mailer.Models.NewCommentEmail
您链接到的页面在命名空间中使用小写:

namespace Hangfire.Mailer.Models

@Ulf的答案似乎是正确的,但您也提到了前面带有@的任何代码也不起作用(如果我理解正确的话)


视图文件夹中是否有web.config文件?你需要它来配置剃须刀和其他东西。如果它不在那里,创建一个新项目,并将生成的视图/web.config文件复制粘贴到您自己的文件夹中。

能否显示
Hangfire.Mailer.Models.NewCommentEmail
的类定义?您可以从以下位置退出
@
:mailer@example.com通过设置两个@:
From:mailer@@example.com
仍然显示Model和Hangfire@jerryh91这两个文件是在同一个DLL中吗?我们怎么知道?你在说什么?
namespace Hangfire.Mailer.Models