如何调试温莎城堡安装/注册异常

本文关键字:安装 城堡 注册 异常 何调试 调试 | 更新日期: 2023-09-27 18:36:54

我的团队前段时间尝试开始使用温莎城堡(3.2.0)来获得IoC的好处。我们在开发盒上的试运行变得桃色,但是当我们尝试在生产服务器上运行代码时,它失败了,出现以下异常

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#,而不是温莎)。该服务器是新调试的服务器,仅安装了MVC 4。所有开发盒都安装了 MVC 3,因此问题只能在生产中重现。

我通过二进制注释掉组件注册代码,将批量注册转换为每个组件注册来调试它,然后盯着有问题的组件,直到我单击正确的位置并顿悟。

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

如何调试温莎城堡安装/注册异常

也许这个答案可以帮助你在调试东西时获得更好的信息:https://stackoverflow.com/a/9539679/1158735