C# 如何调试Castle Windsor安装/注册异常

C# 如何调试Castle Windsor安装/注册异常,c#,castle-windsor,C#,Castle Windsor,我的团队不久前曾尝试使用3.2.0版的温莎城堡(Castle Windsor)进行国际奥委会比赛。我们在开发箱上的试运行非常顺利,但是当我们尝试在生产服务器上运行代码时,失败了,出现了以下异常 Application: XXXX Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.FileNo

我的团队不久前曾尝试使用3.2.0版的温莎城堡(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[])
应用程序:XXXX
框架版本:v4.0.30319
描述:由于未处理的异常,进程已终止。
异常信息:System.IO.FileNotFoundException
堆栈:
在System.Signature.GetSignature(Void*,Int32,System.RuntimeFieldHandleInternal,System.IRuntimeMethodInfo,System.RuntimeType)
在System.Reflection.RuntimeMethodInfo.get_Signature()中
在System.Reflection.RuntimeMethodInfo.GetParametersNoCopy()中
位于System.Reflection.RuntimePropertyInfo.GetIndexParametersNoCopy()处
在System.Reflection.RuntimePropertyInfo.GetIndexParameters()中
位于Castle.MicroKernel.ModelBuilder.Inspectors.propertiesDependenciesModelInspect.IsValidPropertyDependency(System.Reflection.PropertyInfo)
在System.Linq.Enumerable+WhererrayIterator`1[[System.\u Canon,mscorlib,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089]]处。MoveNext()
在System.Collections.Generic.List`1[[System.Collections.Generic.IEnumerable`1]
位于System.Linq.Enumerable.ToList[[System.Collections.Generic.IEnumerable`1]的System.Linq.Enumerable.ToList[[System.\uu Canon,mscorlib,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089]
位于Castle.MicroKernel.ModelBuilder.Inspectors.properties dependenciesmodelinspect.InspectProperties(Castle.Core.ComponentModel)
在System.Collections.Generic.List`1[[System.\uu Canon,mscorlib,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089]]中。ForEach(System.Action`1)
位于Castle.MicroKernel.ModelBuilder.DefaultComponentModelBuilder.buildModelModel(Castle.MicroKernel.ModelBuilder.IComponentModelDescriptor[])
在Castle.MicroKernel.Registration.ComponentRegistration`1[[System.\uu Canon,mscorlib,Version=4.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089]].Castle.MicroKernel.Registration.Register(Castle.MicroKernel.ikerninternal)
位于Castle.MicroKernel.DefaultKernel.Register(Castle.MicroKernel.registation.ireRegistration[])
在Castle.Windsor.WindsorContainer.Register(Castle.MicroKernel.registation.i注册[])
安装(Castle.Windsor.IWindsorContainer、Castle.MicroKernel.subsystem.Configuration.IConfigurationStore)
安装(Castle.Windsor.IWindsorContainer、Castle.MicroKernel.subsystem.Configuration.IConfigurationStore)
位于Castle.Windsor.Installer.CompositeInstaller.Install(Castle.Windsor.IWindsorContainer、Castle.MicroKernel.subsystem.Configuration.IConfigurationStore)
位于Castle.Windsor.WindsorContainer.Install(Castle.MicroKernel.Registration.IWindsorInstaller[],Castle.Windsor.Installer.DefaultComponentInstaller)
位于Castle.Windsor.WindsorContainer.Install(Castle.MicroKernel.Registration.IWindsorInstaller[])
这对我们来说是一个阻碍,对谷歌来说是相当困难的。我最近花了一些时间讨论这个问题,并成功地调试了它,因为一个组件在MVC3DLL上有一个显式引用/依赖项(C#,而不是windsor)。这台服务器是新调试的,只安装了MVC4。所有的开发设备都安装了MVC 3,这使得问题只能在生产中重现

我通过对组件注册码进行二进制注释,将批量注册转换为每个组件注册,然后盯着有问题的组件,直到我点击了正确的位置并顿悟,从而调试了这个组件


我现在的问题是,有没有更好的方法来调试这个?我能让温莎提供更好的信息吗?为什么这对温莎来说是个问题,而不是在正常的非温莎情况下?我和团队现在对使用Windsor有点怀疑,因为不可谷歌搜索的错误只会在生产中重现,所以我希望我错过了一些解决这个问题的好方法。

这个答案是否可以帮助您在调试东西时获得更好的信息:

这里有相同的问题。当windsor失败时,调试非常困难,特别是在IISI中,很久以前就停止使用IoC了,这是一种反模式。IoC使代码绑定不那么紧密,但代价是您不能只按F12键来跟随方法名来实现它。还有这样的问题。太多人选择国际奥委会是因为它听起来既花哨又复杂。通常是IoC与EF和存储库层:这几乎永远不会发生。不管怎样-马匹的课程:有时你只需要一个单例模式,或工厂模式,或继承(记得面向对象吗?),或静态方法调用。很抱歉,我今天帮不了你。单链接答案,即使是SO问答,对SO来说也不太好。这应该是一个评论。