下面这个回报是相关代码:什么是错的,从一个异步函数
Protected Async Function GetMonthlyBillsAsync(month As Date) As Task(Of IDictionary(Of String, Lazy(Of iBill)))
Dim invoiceNumbers = New Dictionary(Of String, Lazy(Of PlumbersSuppliesCoOpBill))
'Stuff to fill the dictionary which works giving 66 elements
Return invoiceNumbers
End Function
从名为:
Dim thisMonth = Await GetMonthlyBillsAsync(sd)
当return语句执行我得到一个的NullReferenceException有:
System.NullReferenceException was unhandled
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=ConsoleApplication1
StackTrace:
at ConsoleApplication1.Module1.Main() in \\fileserver\data\Users\Dale\Visual Studio Projects\SupplierBills\ConsoleApplication1\Module1.vb:line 7
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
这是怎么回事?
你是说你的逻辑没有异步/等待关键字? – anthonybell
好问题 - 我会检查 –