“正在使用"未检测到命名空间检查的客户端分析 [英] 'Using' not detecting namespace-checked client profiling already

查看:35
本文介绍了“正在使用"未检测到命名空间检查的客户端分析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

在 X.Domain 命名空间/项目中,有公共方法,所以我不确定为什么没有公开它.我在stackoverflow上查看了这些链接,但它们没有解决问题.Visual Studio 2010 突然看不到命名空间?,​​找不到类型或命名空间名称类型或命名空间MyNamespace"不存在等

值得一提的是,有人发帖说这可能与错过配置的 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/ 并正在关注 Pro ASP.NET MVC3 Framework 书籍第 164 页上的一些附加代码来创建控制器.

PersonController.cs

使用系统;使用 System.Collections.Generic;使用 System.Linq;使用 System.Web;使用 System.Web.Mvc;使用 KLTMCInsight.Domain.Abstract;命名空间 KLTMCInsight.WebUI.Controllers{公共类 PersonController :控制器{私有只读 IPersonRepository 存储库;公共人员控制器(IPersonRepository personRepository){存储库 = personRepository;}}}

Global.asax

使用系统;使用 System.Collections.Generic;使用 System.Linq;使用 System.Web;使用 System.Web.Mvc;使用 System.Web.Routing;使用 System.Reflection;使用 Ninject;使用 Ninject.Modules;使用 Ninject.Web.Mvc;命名空间 KLTMCInsight.WebUI{公共类 MvcApplication : NinjectHttpApplication{public static void RegisterGlobalFilters(GlobalFilterCollection 过滤器){过滤器.添加(新的处理错误属性());}public static void RegisterRoutes(RouteCollection 路由){routes.IgnoreRoute("{resource}.axd/{*pathInfo}");路线.MapRoute("Default",//路由名称"{controller}/{action}/{id}",//带参数的 URL新 { 控制器 = 首页",动作 = 索引",id = UrlParameter.Optional });}受保护的覆盖 IKernel CreateKernel(){var kernel = new StandardKernel();kernel.Load(Assembly.GetExecutingAssembly());返回内核;}受保护的覆盖 void OnApplicationStarted(){base.OnApplicationStarted();AreaRegistration.RegisterAllAreas();RegisterGlobalFilters(GlobalFilters.Filters);RegisterRoutes(RouteTable.Routes);}}}

如果我遗漏了你需要的东西,我会很高兴把它贴出来.再次感谢您的帮助 - 非常感谢.

解决方案

解决方案如下:

我使用了项目"文件菜单下列出的项目依赖项"框来选择 X.WebUI 项目的依赖项.即使在其中我已经选中了 X.WebUI 项目依赖于 X.Domain 项目的框...该引用从未由 VS2010 创建.

为了解决这个问题,这是一个简单的修复通过手动右键单击 X.WebUI 下的 References 文件夹,并通过该窗口添加对 X.Domain 的引用.添加了参考问题解决了.

不知道为什么一开始没有从项目依赖项"框中进行引用,但如果有人遇到同样的问题 - 这应该提醒您检查引用是否实际进行.

I have a C# solution composed of three projects in Visual Sudio 2010. One is X.Domain (class library) the second, X.UnitTest and the third X.WebUI (MVC3). I was having problems with the using statement to reference the X.Domain namespace from withing the X.WebUI namespace. I thought it was a client profiling issue and verifired that all of the projects where using ".Net Framework 4" as the target framework. I checked to make sure the project dependencies for X.WebUI included the namesapce X.Domain. The exact errors I'm getting are: The type or namespace name 'Domain' does not exist in the namespace'X' (are you missing an assembly reference). The error for the interface I'm trying to use from within X.Domain.Abstract: The type or namespace name 'IPersonRepository' could not be found (are you missing a using directive or an assembly reference)

In the X.Domain namespace/project, there are public methods, so I'm not sure why it's not exposed. I looked into these links here on stackoverflow, but they did not resolve the issue. Visual Studio 2010 suddenly can't see namespace?, The type or namespace name could not be found , The type or namespace 'MyNamespace' does not exist etc

It's worth mentioning that someone posted that it could have something to do with a missed configured global.asax file, here Type or namespace name does not exist in that link, but I'm not sure about it. Could be the case, so I am posting my Global.asax file as well. I noticed the problem when I'm trying to create my 'PersonController' with ninject MVC3, I used Remo.gloo's blog to help me create the Global.asax file as posted here http://www.planetgeek.ch/2010/11/13/official-ninject-mvc-extension-gets-support-for-mvc3/ and am following along with some additional code on p.164 of the the Pro ASP.NET MVC3 Framework book to create the controller.

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);
        }
    }
}

If I missed something you need, I'll be more than glad to post it up. Again, Thank you for your help- Very appreciated.

解决方案

Here is the solution:

I had used the 'Project Dependencies' box listed under the 'Project' file menu to select the dependencies of the X.WebUI project. Even though on in it I had checked the box for the X.WebUI project to depend on the X.Domain project... the reference was never created by VS2010.

To solve the issue it was a simple fix by manually right-clicking the References folder under X.WebUI, and adding the reference to X.Domain through that window. Reference was added problem solved.

Not sure why the reference was not made from the 'Project Dependencies' box in the first place, but if anyone comes across this same problem- this should remind you to check if the reference was actually made.

这篇关于“正在使用"未检测到命名空间检查的客户端分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆