【问题标题】:Constructor on type: "Namespace.type" not found类型的构造函数:找不到“Namespace.type”
【发布时间】:2010-12-12 15:43:32
【问题描述】:

我使用 Castle.Windsor 作为 IOC。

所以我试图在 HTTPHandler 的构造函数中解析服务类型。我不断收到此错误,“Constructor on type: "Namespace.type" not found.” 我的配置具有以下服务类型条目: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>

在我的新处理程序中,构造函数如下所示:

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

我在使用 Castle.Windsor 时从未收到过此错误。有人可以解释吗?

谢谢!

【问题讨论】:

  • IDocumentDirectory的实现提供了什么?
  • HeartBeatHttpHandler 实例是否也使用 windsor 检索?如果是这样,您能否显示 HeartBeatHttpHandler 的 Windsor 组件配置
  • 您的错误信息中“Namespace.type”的真正价值是什么?

标签: c# asp.net castle-windsor ioc-container


【解决方案1】:

您不能将依赖项注入托管的 .NET HTTPHandler 代码。实现 IHttpHandler 的对象必须有一个无参数构造函数

我改用了应用程序容器。这不是我的第一选择。

-尼克

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-24
    • 1970-01-01
    相关资源
    最近更新 更多