Castle Windsor WcfFacility错误。忘了注册组件?

时间:2012-11-23 15:28:17

标签: wcf castle-windsor wcffacility

我想让Castle Windsor使用WcfFacility创建我的WCF。我按照本教程。 http://www.codeproject.com/Articles/426770/Dependency-Injection-in-WCF-using-Castle-Windsor但它似乎对我不起作用。我收到以下错误。

找不到名为ActionService.ServiceImplementations.ActionWebService的组件,您是否忘记注册?

我的应用程序的结构方式如下。

一个webservice项目(只有没有代码的svc文件,web.config和global.asax)

合同和实施的第二个项目。这是IActionWebService和ActionWebservice所在的位置。

我将后者引用到第一个。

这是我的全球性问题。

public class Global : System.Web.HttpApplication
{
    IWindsorContainer container;
    protected void Application_Start(object sender, EventArgs e)
    {
        container = new WindsorContainer();

        container.AddFacility<WcfFacility>()
            .Register(
            Component.For<IAuthService>().ImplementedBy<AuthService>(),
            Component.For<IUserRepository>().ImplementedBy<UserRepository>(),
            Component.For<IActionWebService>().ImplementedBy<ActionWebService>().Named("ActionWebService")
            );
    }

这是我的svc文件。

    <%@ ServiceHost 
Language="C#" 
Debug="true" 
Service="ActionService.ServiceImplementations.ActionWebService"
Factory="Castle.Facilities.WcfIntegration.DefaultServiceHostFactory, Castle.Facilities.WcfIntegration" %>

我已经在这里和其他博客中遇到了其他问题,但他们的解决方案对我没有任何帮助:(。

任何可以指出错误可能发生在哪里的人?

EDIT 我附上了一个Watch Window捕获。在那里你可以看到所有对象似乎都被加载了。但它并没有解决它们。

Here you can see that the actual objects are loaded in the container. It just doesn't resolve them

2 个答案:

答案 0 :(得分:1)

我有同样的错误

要在注册的字符串参数中解决它,我把它与完整的命名空间一样。

protected void Application_Start(object sender, EventArgs e)
    {
        IWindsorContainer container = new WindsorContainer();

        container.AddFacility<WcfFacility>().Register(
          Component.For<IActivityLogsRepository>().ImplementedBy<ActivityLogsRepository>(),
            Component.For<IActivityLogsService>().ImplementedBy<ActivityLogsService>()
                .Named("Company.ServiceImplementation.ActivityLogsService"),

我希望这可以帮到你

答案 1 :(得分:1)

我遇到了同样的问题,这是因为在svc文件标记代码仍引用旧dll名称的同时,我们项目的输出dll名称已更改:

2