【发布时间】:2016-03-14 20:53:25
【问题描述】:
我正在尝试从我的 .NET Web 服务中的测试脚本调试异步调用,但我的异步调用中的断点永远不会被命中。我什至尝试在其中放置一个 Debugger.Break() 。下面是调用代码...
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(ConfigurationManager.AppSettings["BaseAddress"]);
string uri = "/api/Rd_Regions";
// Below is the line of code I want to step into, but it won't step into the 'client.GetAsync(uri)'...
HttpResponseMessage response = await client.GetAsync(uri);
if (response.IsSuccessStatusCode)
{
// Convert the result into business object
// Do stuff...
}
else do other stuff...
应该在断点所在的位置调用 web 服务的部分,首先是 web api 的上下文,然后是被调用的方法。如果它停在其中一个,我会很高兴......
public partial class PIMSContext : DbContext
{
public PIMSContext()
: base(new OracleConnection(Security.ConfigurationReader.GetAppSetting("PIMS")), true)
//: base(new OracleConnection(ConfigurationManager.ConnectionStrings["PIMS"].ConnectionString), true)
etc....
这是最终调用的方法:
// GET: api/RD_REGIONS
public IQueryable<RD_REGIONS> GetRD_REGIONS()
{
// I want the debugger to stop here!
Debugger.Break();
return db.RD_REGIONS;
}
我错过了什么吗?不能单步执行这个异步调用吗? 任何见解都值得赞赏。
【问题讨论】:
-
你在用测试方法调试吗?还是通过网络浏览器?
-
是的,我正在通过 Visual Studio Online 2015 中的测试方法调试服务。我在调试模式下构建并在异步调用之前的行停止,当我尝试 F11 时(步骤into) 异步调用它只是跳到下一行。
标签: c# asynchronous visual-studio-debugging