2013-10-26 53 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

回答

相关问题