构造函数类型:" Namespace.type"未找到 [英] Constructor on type: "Namespace.type" not found

查看:264
本文介绍了构造函数类型:" Namespace.type"未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Castle.Windsor作为国际奥委会。

I am using Castle.Windsor as an IOC.

所以我试图解决一个HttpHandler的构造函数的服务类型。我不断收到此错误,构造的类型:Namespace.type未找到我的配置有服务类型如下条目:IDocumentDirectory

So I am trying to resolve a service type in the constructor of an HTTPHandler. I keep receiving this error, "Constructor on type: "Namespace.type" not found." My configuration has the following entries for service type: IDocumentDirectory

<component id="restricted.content.directory" service="org.myorg.foundations.services.content.IDocumentDirectory, org.myorg.foundations.services" type="org.myorg.foundations.services.content.RestrictedLocalizationDocumentDirectory, org.myorg.foundations.services">
    <parameters>
      <contentDirectory>${content.directory}</contentDirectory>
      <localizations>
        <array>
          <item>en-us</item>
          <item>es-us</item>
        </array>
      </localizations>
    </parameters>
  </component>

  <component id="content.directory" service="org.myorg.foundations.services.content.IDocumentDirectory, org.myorg.foundations.services" type="org.myorg.foundations.services.web.client.WebServiceDocumentDirectory, org.myorg.foundations.services.web.client">
    <parameters>
      <webServiceURL>#{contentDirectoryWebsiteUrl}</webServiceURL>
    </parameters>
  </component>

在我的新的处理程序的构造是这样的:

In my new handler the constructor looks like this:

 public HeartBeatHttpHandler(IDocumentDirectory contentDirectory)
    {
        _contentDirectory = contentDirectory;
    }

我从来没有使用Castle.Windsor收到此错误。有人能解释一下吗?

I have never recieved this error using Castle.Windsor. Can someone explain?

谢谢!

推荐答案

您不能注入依赖到托管的.NET的HttpHandler code。实现IHttpHandler的对象的必须有一个无参数的构造函数

You cannot inject a dependency into managed .NET HTTPHandler code. The objects that implement IHttpHandler must have a parameter-less constructor.

我使用的应用程序容器而不是。这不会是我的第一选择。

I used an application container instead. Which wouldn't have been my first choice.

-Nick

这篇关于构造函数类型:&QUOT; Namespace.type&QUOT;未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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