【问题标题】:The type of namespace name could not be found (are you missing a using directive or an assembly reference?)找不到命名空间名称的类型(您是否缺少 using 指令或程序集引用?)
【发布时间】:2014-09-02 10:38:38
【问题描述】:

我有这门课:

using System;
using System.Web.Mvc;
using System.Data;
using BLL;

namespace LicenseManager.Controllers
{
    public class ValidationController : BaseController
    {
        public ActionResult Default()
        {
            return View("Default");
        }

        [HttpPost]
        public JsonResult ClearInstallation(FormCollection form)
        {
            var jr = new JsonResult();
            try
            {
                var licMgr = new BLL.LicManager();
                licMgr.ClearInstall(form["regKey"], form["checkKey"]);

            }
            catch (Exception exc)
            {
                jr = Json(new { success = "false", error = exc.Message });
            }

            return jr;
        }
    }
}

当我尝试重建或调试时,我收到错误:The type of namespace name 'BLL' could not be found (are you missing a using directive or an assembly reference?)

我可以看到它被引用了:

智能感知有效,在我尝试重建或编译之前,我没有任何错误。我知道它存在,并且它发现它是为了智能感知,那为什么它不允许我重建或编译呢?

我试过了:

  • 清洗溶液
  • 重建
  • 清除引用并重新添加它

我还能尝试什么?

更新 如果您收到此错误,请确保您阅读了输出。它包含了我的解决方案。

【问题讨论】:

  • 当引用的项目使用不同的 .net 框架时,我遇到了类似的问题。你确认他们匹配了吗?您可以在属性/应用程序/目标框架中验证/更改框架
  • 它们不同,它解决了我的问题。如果您将其发布为答案,我会接受。

标签: c# reference namespaces


【解决方案1】:

当引用的项目使用不同的 .net 框架时,我遇到了类似的问题。确保您正在构建的项目和您引用的项目使用相同的框架。

您可以在属性/应用程序/目标框架中验证/更改框架

【讨论】:

  • 我应该仔细调查一下。结果显示输出窗格解释说目标框架不匹配。
  • 你收到警告了吗?
  • 如果警告是指列出的错误,是的。否则,它只会给出错误。但是,在输出中的详细信息中,它告诉我 BLL 的目标框架与解决方案的目标不匹配。
猜你喜欢
  • 2013-08-28
  • 1970-01-01
  • 1970-01-01
  • 2012-05-01
  • 2020-11-28
  • 2015-06-12
  • 2015-04-19
  • 2013-05-22
  • 2020-03-29
相关资源
最近更新 更多