我在为Castle.Windsor IoV组件连接事件时遇到问题。即使我已经确认了它们的方法和签名,它也会抛出一个异常,消息“对象与目标类型不匹配”。
任何人都可以解释一下它期待的对象吗?
我的布线如下:
<component
id="mailManager"
service="Pop3Dispatcher.Mail.IMailManager, Pop3Dispatcher"
type="Pop3Dispatcher.Mail.DefaultMailManagerImpl, Pop3Dispatcher"
startable="true"
loadCompletedMethod="Init">
<subscribers>
<subscriber id="emailFilterImpl" event="MessageRecieved" handler="OnReceivedMessage"/>
</subscribers>
</component>
<component
id="emailFilterImpl"
service="Pop3Dispatcher.Filters.IFilter, Pop3Dispatcher"
type="Pop3Dispatcher.Filters.EmailFilterImpl, Pop3Dispatcher"
startable="true">
</component>
在有人问之前,是的,我已经包括:
<facilities>
<facility
id="event.wiring"
type="Castle.Facilities.EventWiring.EventWiringFacility, Castle.MicroKernel" />
</facilities>
答案 0 :(得分:0)
好的,问题解决了,显然在这种情况下,申报的顺序很重要。 Alos,它不支持“服务”,必须直接订阅该类型。
<component
id="emailFilterImpl"
type="Pop3Dispatcher.Filters.EmailFilterImpl, Pop3Dispatcher"
startable="true">
</component>
<component
id="mailManager"
type="Pop3Dispatcher.Mail.DefaultMailManagerImpl, Pop3Dispatcher"
startable="true"
loadCompletedMethod="Init">
<subscribers>
<subscriber id="emailFilterImpl" event="MessageRecieved" handler="OnReceivedMessage"/>
</subscribers>
</component>