0
我嘗試在Castle Windsor註冊組件時指向WCF服務的組件出現錯誤消息。對於註冊組件我使用:在溫莎城堡註冊wcf客戶端組件的正確錯誤消息
container.Register(Component.For<MembershipService>().ImplementedBy<MembershipServiceClient>.LifeStyle.Transient);
配置文件有以下兩個條目(綁定指向一個不存在的文件):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings configSource="Configs\local\nonexistingbindingfile.xml"/>
<client configSource="Configs\local\system.serviceModel.client.xml"/>
</system.serviceModel>
</configuration>
什麼情況是,城堡不會失敗註冊我的組件但它不會解析MembershipService以獲取其他組件的任何依賴關係,它會將該屬性設置爲null,但此時我沒有任何指向具有該問題的文件的錯誤日誌,故障排除變得非常困難。
謝謝。
謝謝,我收到了我正在尋找的錯誤消息。使用構造函數注入將使依賴不可選。有沒有辦法通過屬性注入非選擇性來解決所有依賴問題? – Ajadex 2011-06-08 13:46:03
不是我知道亞歷克斯。這是Property和Constructor注入的關鍵區別。 – 2011-06-08 22:55:59