下面這個回報是相關代碼:什麼是錯的,從一個異步函數
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
好問題 - 我會檢查 –