Closed BenBach closed 14 years ago
seems like i had forgotten to update the codes in the main master branch. it works well in the dev branch.
anyways i have now merged it to the master branch.
can you download the code again and try.
let me know if u still have problems.
Thank you. I still have the same problems. Do u use the .Net version 4 or 3.5?
I debuged. Some deserialization works. It doesnt work for the "hometown" attribute
For the elements before the TokenType in the JsonReader is String. For hometown it's StartObject
If i remove hometown from my profile it's working
For the time being try using
string result = fb.Get("/me"); IDictionary<string,object> json = FacebookUtils.FromJson(result); var name = json["name"].ToString();
I will have a look at the hometown issue.
For the Facebook# samples im using .net 4.0, but for my internal project im using .net 3.5.
This issue has been fixed now. You can now safely call fb.Get<User>("/me"). Hometown will get deserialized correctly.
Please check the latest source code again.
I tried the Canvas example, but somehow i dont get it to work.
When trying to deserialize the User object following exception is thrown:
Newtonsoft.Json.JsonSerializationException was unhandled by user code Message=Cannot deserialize JSON object into type 'System.String'. Source=Newtonsoft.Json StackTrace: at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueProperty(JsonReader reader, JsonProperty property, Object target, Boolean gottenCurrentValue, Object currentValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonReader reader, Object target) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateAndPopulateObject(JsonReader reader, JsonObjectContract contract, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueNonProperty(JsonReader reader, Type objectType, JsonContract contract) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value) at FacebookSharp.FacebookUtils.DeserializeObject[T](String json) in C:\Users\Ben\Downloads\prabirshrestha-FacebookSharp-97483f1\prabirshrestha-FacebookSharp-97483f1\src\FacebookSharp.Core\FacebookUtils_FacebookUtils.cs:line 116 at FacebookSharp.Facebook.Get[T](String graphPath, IDictionaryb a()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
InnerException:
2 parameters, Boolean addAccessToken) in C:\Users\Ben\Downloads\prabirshrestha-FacebookSharp-97483f1\prabirshrestha-FacebookSharp-97483f1\src\FacebookSharp.Core\OfficialFacebookSdkCompatibilityApi.Sync.cs:line 397 at FacebookSharp.Facebook.Get[T](String graphPath, IDictionary
2 parameters) in C:\Users\Ben\Downloads\prabirshrestha-FacebookSharp-97483f1\prabirshrestha-FacebookSharp-97483f1\src\FacebookSharp.Core\OfficialFacebookSdkCompatibilityApi.Sync.cs:line 207 at FacebookSharp.Facebook.Get[T](String graphPath) in C:\Users\Ben\Downloads\prabirshrestha-FacebookSharp-97483f1\prabirshrestha-FacebookSharp-97483f1\src\FacebookSharp.Core\OfficialFacebookSdkCompatibilityApi.Sync.cs:line 178 at FacebookSharp.Samples.CanvasIFrameApplication.Controllers.HomeController.Index() in C:\Users\Ben\Downloads\prabirshrestha-FacebookSharp-97483f1\prabirshrestha-FacebookSharp-97483f1\src\Samples\FacebookSharp.Samples.CanvasIFrameApplication\Controllers\HomeController.cs:line 93 at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 parameters) at System.Web.Mvc.ControllerActionInvoker.<>cDisplayClassd.