不包含"GetAwaiter"的定义 [英] does not contain a definition for 'GetAwaiter'
问题描述
我在使用以下代码集时遇到以下错误,在"alliancelookup"行中出错,我不确定自己在做什么错,但是我自己什么也看不到.我正在查询的查询似乎运行良好,但是似乎等待者遇到了问题,我想知道是否可以解决此问题?
Im getting the below error with the below set of code, It is erroring on the 'alliancelookup' line, I'm not sure what i'm doing wrong but I couldn't see anything myself. The query im running to crest seems to be running fine but It seems the issue im having is with the Awaiter, I was wondering if there was a way around this?
DynamicCrest crest = new DynamicCrest();
var root = await crest.GetAsync(crest.Host);
var alliancelookup = await (await root.GetAsync(r => r.alliances)).First(i => i.shortName == e.GetArg("allianceticker").ToUpper());
allianceid = alliancelookup.id;
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:"System.Dynamic.ExpandoObject"不包含"GetAwaiter"的定义 在CallSite.Target(Closure,CallSite,Object) 在System.Dynamic.UpdateDelegates.UpdateAndExecute1 [T0,TRet](CallSite站点,T0 arg0)处 在***.Program.<> c.< b__2_10> d.MoveNext()中的C:\ Users --- \ Documents \ Visual Studio 2015 \ Projects ------ \ Program.cs:line 95
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'System.Dynamic.ExpandoObject' does not contain a definition for 'GetAwaiter' at CallSite.Target(Closure , CallSite , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0) at ***.Program.<>c.<b__2_10>d.MoveNext() in C:\Users---\Documents\Visual Studio 2015\Projects------\Program.cs:line 95
推荐答案
在没有最小,完整,可验证的情况下,不可能确切知道出了什么问题例子,但看起来确实是在await
进行了本来不是await
的事情.
It's not possible to know exactly what's wrong without a minimal, complete, verifiable example, but it does look like you're await
ing something that isn't meant to be await
ed.
拆分alliancelookup
行:
// Asynchronously retrieve the alliances.
var alliances = await root.GetAsync(r => r.alliances);
// Synchronously get the first matching one.
var allianceLookup = alliances.First(i => i.shortName == e.GetArg("allianceticker").ToUpper());
也许有更好的方法,将过滤器移到异步代码中,但这取决于DynamicCrest
.
There may be a better approach, moving the filter into the async code, but that depends on DynamicCrest
.
这篇关于不包含"GetAwaiter"的定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!