1
我有麻煩,使用StructureMap將WCF服務客戶端注入到Controller的構造函數中。無法在ASP.NET MVC中注入WCF服務依賴關係使用StructureMap
我跟着Phil Haack's example on DI in ASP.NET MVC
的WCF服務,我有被稱爲LogService。它實現了ILogService。
的StructureMap.config看起來是這樣的:
<?xml version="1.0" encoding="utf-8" ?>
<StructureMap>
<Assembly Name="Yakinix.Admin.Web" />
<Assembly Name="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<PluginFamily Type="System.Web.Mvc.IController" Assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<Plugin Type="Yakinix.Admin.Web.Controllers.HomeController" ConcreteKey="home" Assembly="Yakinix.Admin.Web" />
</PluginFamily>
<PluginFamily Type="Yakinix.Admin.Web.LogService.ILogService" Assembly="Yakinix.Admin.Web" DefaultKey="WcfLogService">
<Plugin Assembly="Yakinix.Admin.Web" Type="Yakinix.Admin.Web.LogService.LogServiceClient" ConcreteKey="WcfLogService" />
</PluginFamily>
</StructureMap>
得到拋出的錯誤是這樣的:
StructureMap異常代碼:200
找不到一個InstanceMemento爲 請求InstanceKey PluginFamily的「WcfLogService」 Yakinix.Admin.Web.LogService.ILogService
你有什麼想法嗎?
我不認爲這就是他所要求的。他希望將「WCF服務」注入「某些東西」,而該投影則顯示了向WCF服務注入「某些東西」的示例。 – drozzy 2012-10-12 13:50:46