在发布版本中,在 Microsoft Unity 解析期间,如果抛出任何异常,则 StackTrace 没有发生异常的“行号”。如果没有这些信息,调试可能会很麻烦……你们是怎么处理的?
我想这是由于 Microsoft Uniy 使用 Reflection.Emit。我的猜测正确吗?
下面是例子
Project ABC uses Microsoft Unity to resolve ViewModel XYZ during initilization.
XYZViewModel constructor throws an exception.
Source : Microsoft.Practices.Unity
Message : Resolution of the dependency failed, type = "XYZViewModel", name = "(none)".
Exception occurred while: Calling constructor XYZViewModel().
Exception is: Exception - test exception StrackTrace line number
在异常发生时,容器是:
Resolving XYZViewModel,(none)
Calling constructor XYZViewModel()
////// no line number in XYZViewModel code
Type : Microsoft.Practices.Unity.ResolutionFailedException
TargetSite : System.Object DoBuildUp(System.Type, System.Object, System.String, System.Collections.Generic.IEnumerable`1[Microsoft.Practices.Unity.ResolverOverride])
StackTrace : at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides) in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\UnityContainer.cs:line 515
////// has line number in Microsoft Unity code
at Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides) in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\UnityContainer.cs:line 173
///// has line number in Microsoft Unity code