如何在异步中获取行号等待C#

时间:2016-03-30 02:01:53

标签: c# async-await

我正在调查使用async / await时的错误。但是,它显示如下,并且不显示行号。

System.UnauthorizedAccessException: Access to the port is denied. 
at System.IO.Ports.InternalResources.WinIOError(Int32 errorCode, String str) 
at System.Threading.Semaphore..ctor(Int32 initialCount, Int32 maximumCount, String name) 
at StorageServiceIntegration.Managers.StorageServiceManager.d__41.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
at StorageServiceIntegration.Managers.StorageServiceManager.d__33.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
at StorageServiceIntegration.Managers.StorageServiceManager.d__32.MoveNext()

如何显示行号以及代码失败的位置?我正在使用.Net 4.6.1

1 个答案:

答案 0 :(得分:2)

确保在Visual Studio中构建调试模式。