我试图让城堡温莎创建我的WCF使用WcfFacility。我遵循了这个教程。http://www.codeproject.com/Articles/426770/Dependency-Injection-in-WCF-using-Castle-Windsor,但它似乎对我不起作用。我得到了以下错误。
ActionService.ServiceImplementations.ActionWebService,找不到一个具有名称的组件,您忘记注册它了吗?
我的应用程序的结构方式如下。
webservice的一个项目(只有svc文件没有后面的代码,web.config和global.asax)
合同和实现的第二个项目。这就是IActionWebService和ActionWebservice所在的地方。
我有后一个的参考第一个。
这是我的全球asax。
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" %>我已经在这里和其他博客上浏览过其他问题,但是他们的解决方案对我没有任何帮助。
有人能指出错误可能发生在哪里吗?
编辑我附加了一个监视窗口捕获。在这里,您可以看到所有的对象似乎都被加载了。但它不能解决这些问题。

发布于 2013-02-13 18:15:35
我也犯了同样的错误
为了在注册的字符串参数中解决这个问题,我将它与完整的名称空间放在一起,如下所示。
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"),我希望这能帮到你
发布于 2018-08-22 19:18:58
我遇到了同样的问题,这是因为我们的项目的输出dll名称被更改了,而svc文件标记代码仍然引用旧的dll名称:
<%@ ServiceHost Language="C#" Debug="true" Service="[Namespace.ClassName],[DllName]" Factory="Castle.Facilities.WcfIntegration.DefaultServiceHostFactory, Castle.Facilities.WcfIntegration" %>https://stackoverflow.com/questions/13531938
复制相似问题