Getting exception when using Async client.

May 30, 2010 at 7:49 PM

I am trying to call GetUser method on the StackOverflowClientAsync object but I'm getting the following error:

Exception has been thrown by the target of an invocation.

   at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
   at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
   at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
   at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at StackStats.Program.Main(String[] args) in E:\share\giusia\My Dropbox\Personal\Misc\StackStats\StackStats\Program.cs:line 19
   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.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Inner exception:

"Cannot deserialize JSON object into type 'System.Collections.Generic.List`1[StackOverflow.User]'."

at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, Object existingValue) in d:\Development\Source\Json\trunk\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 332
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValue(JsonReader reader, Type objectType, JsonContract contract, Object existingValue, JsonConverter memberConverter) in d:\Development\Source\Json\trunk\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 190
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType) in d:\Development\Source\Json\trunk\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 114
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) in d:\Development\Source\Json\trunk\Src\Newtonsoft.Json\JsonSerializer.cs:line 402
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType) in d:\Development\Source\Json\trunk\Src\Newtonsoft.Json\JsonSerializer.cs:line 394
   at StackOverflow.SerializationHelper.DeserializeJson[T](String json) in E:\Code\StackOverflow.Net\trunk\StackOverflow.Net\Helpers\SerializationHelper.cs:line 50
   at StackOverflow.JsonResponse`1.Parse[T](String json, JsonResponse`1 response) in E:\Code\StackOverflow.Net\trunk\StackOverflow.Net\Protocols\JsonResponse.cs:line 43
   at StackOverflow.JsonResponse`1..ctor(String json) in E:\Code\StackOverflow.Net\trunk\StackOverflow.Net\Protocols\JsonResponse.cs:line 30
   at StackOverflow.JsonProtocol.GetResponse[T](String message) in E:\Code\StackOverflow.Net\trunk\StackOverflow.Net\Protocols\JsonProtocol.cs:line 9
   at StackOverflow.StackOverflowClientAsync.<>c__DisplayClass1a`1.<MakeRequest>b__18(HttpResponse response) in E:\Code\StackOverflow.Net\trunk\StackOverflow.Net\StackOverflowClientAsync\StackOverflowClientAsync.cs:line 87
   at StackOverflow.UrlClientAsync.client_DownloadDataCompleted(Object sender, DownloadDataCompletedEventArgs e) in E:\Code\StackOverflow.Net\trunk\StackOverflow.Net\UrlClientAsync.cs:line 68
   at System.Net.WebClient.OnDownloadDataCompleted(DownloadDataCompletedEventArgs e)
   at System.Net.WebClient.DownloadDataOperationCompleted(Object arg)

Not async version works without any problems.

Coordinator
May 30, 2010 at 9:26 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.