2011-11-03 156 views
0

在發佈版本中,在Microsoft Unity解析期間,如果有任何異常拋出,StackTrace沒有發生異常的「行號」。 沒有這些信息,調試可能會很麻煩.... 你們如何處理它?Microsoft Unity在發生異常時丟失了「行號」,我該怎麼辦?

我想這是由於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 
+2

通常,您需要讓C#編譯器生成.pdb(符號文件)以及程序集(exe/dll),以便在應用程序執行時可以打印出行號信息。 –

+0

thx Lex,您是對! – athos

+0

管理員:Lex的評論是正確的解決方案,但他用評論而不是答案,我怎麼能夠關閉這個問題? – athos

回答

0

社區維基。答案在評論中。任何在搜索中發現此主題的人都會看到有答案,並且更有可能尋找有希望的有用答案。 「

」通常,您需要讓C#編譯器生成.pdb(符號文件)以及程序集(exe/dll),以便在應用程序執行時可以打印出行號信息 - Lex Li

相關問題