在发布版本中,在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
答案 0 :(得分:0)
社区维基。答案在评论中。任何在搜索中找到此主题的人都会看到答案,并且更有可能寻找有希望的有用答案。
“通常你需要让C#编译器生成.pdb(符号文件)和程序集(exe / dll),这样当应用程序执行时,可以打印出行号信息。 - {3 }}