si scusate, ma sta sintassi non riesco a digerirla e faccio degli errori stupidi:
però ho comunque un problema:
mi da questa eccezione:codice:Dim result As String = Await content.ReadAsStringAsync() If result IsNot Nothing Then Dim json As String = result.ToString() Dim list As List(Of Book) = JsonConvert.DeserializeObject(json) 'PROBLEMA RIGA 22 For Each item As Book In list books.Add(item) Next End If
la riga 22 è quella ho indicato.codice:Eccezione non gestita: System.InvalidCastException: Impossibile eseguire il cast di oggetti di tipo 'Newtonsoft.Json.Linq.JArray' sul tipo 'System.Collections.Generic.List`1[VBTest.Book]'. in VBTest.Module1.VB$StateMachine_1_SendRequest.MoveNext() in C:\VS_Proj\VBTest\VBTest\Module1.vb:riga 22 --- Fine traccia dello stack da posizione precedente dove è stata generata l'eccezione --- in System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__6_1(Object state) in System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state) in System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) in System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) in System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() in System.Threading.ThreadPoolWorkQueue.Dispatch() in System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

Rispondi quotando