如何读取.Net程序中生成的堆栈跟踪或错误信息以查找异常的根本原因

par*_*agy 4 c# exception

这确实是一个基本问题,可能会重复。谁能告诉我.Net中任何程序生成的错误信息的有用性。

今天,我收到了一个错误消息“发现歧义匹配”。在将实体保存在数据库中(使用EF4)时,我无法弄清楚为什么会出现此错误,根本原因是什么。附件是相同的按扣。

替代文字 这是完整的错误详细信息,

System.Reflection.AmbiguousMatchException was unhandled by user code
     Message=Ambiguous match found.
     Source=mscorlib
     StackTrace:
   at System.RuntimeType.GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
   at System.Type.GetProperty(String name)
   at IAA.Data.EntityFramework.RepositoryWithTypedId`2.SaveOrUpdate[T](T entity)
   at ABC.XYZ.ApplicationServices.AcknowledgementManagementService.SaveOrUpdate(AcknowledgementFormViewModel acknowledgementFormViewModel) in E:\RA\ABC.XYZ\app\ABC.XYZ.ApplicationServices\AcknowledgementManagementService.cs:line 123
   at ABC.XYZ.Web.Controllers.AcknowledgementsController.Acknowledgements(AcknowledgementFormViewModel acknowledgementFormViewModel) in E:\RA\ABC.XYZ\app\ABC.XYZ.Web.Controllers\AcknowledgementsController.cs:line 68
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
Run Code Online (Sandbox Code Playgroud)

InnerException:

Joh*_*ers 5

这意味着System.Reflection.AmbiguousMatchException抛出了一个,并且未对其进行处理。它被扔到System.RuntimeType.GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers),从System.Type.GetProperty(String name)调用,从IAA.Data.EntityFramework.RepositoryWithTypedId2.SaveOrUpdate [T](T entity)` 调用,

等等