';使用';未检测到已检查命名空间的客户端分析

本文关键字:客户端 命名空间 使用 检测 检查 | 更新日期: 2023-09-27 18:19:44

我在Visual Sudio 2010中有一个由三个项目组成的C#解决方案。一个是X.Domain(类库),第二个是X.UnitTest,第三个是X.WebUI(MVC3)。我在使用语句从X.WebUI命名空间中引用X.Domain命名空间时遇到问题。我认为这是一个客户端评测问题,并验证了所有使用".Net Framework 4"作为目标框架的项目。我进行了检查,以确保X.WebUI的项目依赖项包括命名空间X.Domain。我得到的确切错误是:命名空间"X"中不存在类型或命名空间名称"Domain"(是否缺少程序集引用)。我试图从X.Domain.Abstract:找不到类型或命名空间名称"IPersonRepository"(是否缺少using指令或程序集引用)

在X.Domain命名空间/项目中,有一些公共方法,所以我不知道为什么它没有公开。我在stackoverflow上查看了这些链接,但它们并没有解决问题。Visual Studio 2010突然可以';t see namespace?,找不到类型或命名空间名称,类型或命名空间';MyNamespace';不存在etc

值得一提的是,有人发帖称,这可能与一个未配置的global.asax文件有关,如下所示类型或命名空间名称不存在在那个链接中,但我不确定。可能是这样,所以我也发布了我的Global.asax文件。当我试图用ninject MVC3创建我的"PersonController"时,我注意到了这个问题,我使用Remo.gloo的博客来帮助我创建Global.asax文件,如下所示http://www.planetgeek.ch/2010/11/13/official-ninject-mvc-extension-gets-support-for-mvc3/下面是ProASP.NET MVC3 Framework书第164页上的一些附加代码,用于创建控制器。

PersonController.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using KLTMCInsight.Domain.Abstract;

namespace KLTMCInsight.WebUI.Controllers
{
    public class PersonController : Controller
    {
        private readonly IPersonRepository repository;
        public PersonController(IPersonRepository personRepository)
        {
            repository = personRepository;
        }
    }
}

Global.asax

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Reflection;
using Ninject;
using Ninject.Modules;
using Ninject.Web.Mvc;
namespace KLTMCInsight.WebUI
{
    public class MvcApplication : NinjectHttpApplication
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                    new { controller = "Home", action = "Index", id = UrlParameter.Optional    }
            );
        }
        protected override IKernel CreateKernel()
        {
            var kernel = new StandardKernel();
            kernel.Load(Assembly.GetExecutingAssembly());
            return kernel;
        }

        protected override void OnApplicationStarted()
        {
            base.OnApplicationStarted();
            AreaRegistration.RegisterAllAreas();
            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }
    }
}

如果我错过了你需要的东西,我会非常乐意把它寄出去的。再次感谢您的帮助-非常感谢。

';使用';未检测到已检查命名空间的客户端分析

以下是解决方案:

我使用了"项目"文件菜单下列出的"项目依赖项"框来选择X.WebUI项目的依赖项。尽管我在其中选中了X.WebUI项目依赖于X.Domain项目的复选框。。。VS2010从未创建引用。

要解决此问题,只需手动右键单击X.WebUI下的References文件夹,然后通过该窗口将引用添加到X.Domain即可。已添加引用,问题已解决

首先不确定为什么没有从"项目依赖项"框中进行引用,但如果有人遇到同样的问题,这应该提醒您检查是否确实进行了引用。