2013-10-26 54 views
7

我的團隊在一段時間之前嘗試開始使用Castle Windsor(3.2.0)進行IoC優化。我們的審判發展箱運行去桃色的,但是當我們試圖運行在生產服務器上的代碼,它除了具有以下不同如何調試Castle Windsor的安裝/註冊異常

Application: XXXX 
Framework Version: v4.0.30319 
Description: The process was terminated due to an unhandled exception. 
Exception Info: System.IO.FileNotFoundException 
Stack: 
    at System.Signature.GetSignature(Void*, Int32, System.RuntimeFieldHandleInternal, System.IRuntimeMethodInfo, System.RuntimeType) 
    at System.Reflection.RuntimeMethodInfo.get_Signature() 
    at System.Reflection.RuntimeMethodInfo.GetParametersNoCopy() 
    at System.Reflection.RuntimePropertyInfo.GetIndexParametersNoCopy() 
    at System.Reflection.RuntimePropertyInfo.GetIndexParameters() 
    at Castle.MicroKernel.ModelBuilder.Inspectors.PropertiesDependenciesModelInspector.IsValidPropertyDependency(System.Reflection.PropertyInfo) 
    at System.Linq.Enumerable+WhereArrayIterator`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext() 
    at System.Collections.Generic.List`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]..ctor(System.Collections.Generic.IEnumerable`1<System.__Canon>) 
    at System.Linq.Enumerable.ToList[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable`1<System.__Canon>) 
    at Castle.MicroKernel.ModelBuilder.Inspectors.PropertiesDependenciesModelInspector.InspectProperties(Castle.Core.ComponentModel) 
    at System.Collections.Generic.List`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].ForEach(System.Action`1<System.__Canon>) 
    at Castle.MicroKernel.ModelBuilder.DefaultComponentModelBuilder.BuildModel(Castle.MicroKernel.ModelBuilder.IComponentModelDescriptor[]) 
    at Castle.MicroKernel.Registration.ComponentRegistration`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Castle.MicroKernel.Registration.IRegistration.Register(Castle.MicroKernel.IKernelInternal) 
    at Castle.MicroKernel.DefaultKernel.Register(Castle.MicroKernel.Registration.IRegistration[]) 
    at Castle.Windsor.WindsorContainer.Register(Castle.MicroKernel.Registration.IRegistration[]) 
    at Sproom.Web.Infrastructure.WindsorInstaller.Install(Castle.Windsor.IWindsorContainer, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore) 
    at Castle.Windsor.Installer.AssemblyInstaller.Install(Castle.Windsor.IWindsorContainer, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore) 
    at Castle.Windsor.Installer.CompositeInstaller.Install(Castle.Windsor.IWindsorContainer, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore) 
    at Castle.Windsor.WindsorContainer.Install(Castle.MicroKernel.Registration.IWindsorInstaller[], Castle.Windsor.Installer.DefaultComponentInstaller) 
    at Castle.Windsor.WindsorContainer.Install(Castle.MicroKernel.Registration.IWindsorInstaller[]) 

失敗這對我們來說是攪局者和被證明是相當困難的谷歌。我最近有一段時間來解決這個問題,併成功地將它調試到一個組件在MVC 3 dll上具有顯式引用/依賴項(C#,而不是windsor)的事實。服務器是新委託的服務器,只安裝了MVC 4。所有開發包都安裝了MVC 3,這使得問題只能在生產中重現。

我通過二進制註釋掉組件註冊碼,將大量註冊轉換爲每個組件註冊,然後盯着有問題的組件,直到我點擊正確的位置並有一個頓悟。

我的問題是現在,有沒有更好的方式,我可以調試呢?我可以讓溫莎提供更好的信息嗎?那麼,爲什麼溫莎這個問題不屬於正常的非溫莎案件呢?鑑於不可回收的錯誤只能在生產中重複使用,所以我和團隊現在對使用Windsor有點懷疑,所以我希望我錯過了解決這個問題的一些好方法。

+0

同樣在這裏的問題。當windsor失敗時,調試非常困難,尤其是,在IIS –

+0

很久以前,我停止使用IoC,這是一種反模式。 IoC使得代碼的綁定更加緊密,但是代價是您不能只按F12來按照其實現的方法名稱。然後有這樣的問題。太多人選擇IoC是因爲它聽起來很花哨而且很複雜。通常它與EF和Repository層是IoC:應該幾乎不會發生。無論如何 - 課程中的馬:有時你只需要單例模式,工廠模式或繼承(記住面向對象?)或靜態方法調用。對不起,我今天無法幫助你的IoC地獄。 – Todd

回答

相關問題