[CLOSED] Nullable parameters on DirectMethod
Afternoon all,
I've recently updated our Ext.NET dlls to version 1.5.1.0 and seem now to be hitting an exception when calling DirectMethods with nullable parameters.
e.g.
Code:
[DirectMethod]
public void DoSomething(int? lUserID, int? lTeamID, int? lDepartmentID)
{
...
}
Now gives me an exception of this ilk:
Code:
Newtonsoft.Json.JsonReaderException: Unexpected end when reading integer. Line 0, position 0. at Newtonsoft.Json.JsonTextReader.ReadAsInt32() at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter, Boolean inArray) 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 Ext.Net.DirectMethod.Invoke(Object target, HttpContext context, ParameterCollection args) at Ext.Net.ResourceManager.RaisePostBackEvent(String eventArgument)
I thought originally it was because a couple of those params were being passed at an empty string rather than a JS null. So I reworked the calling function to ensure that the JSON was valid, e.g.
Code:
submitDirectEventConfig {"config":{"extraParams":{"lUserID":"1427","lTeamID":null,"lDepartmentID":null}}}
But this still gives the exception.
I did find an old post on here suggesting that Ext.NET prior to version 2 doesn't support nullable parameters, but this seems a little odd as prior to updating things were working happily.
Is this possibly due to the version of JSON.NET used? or is there a sensible workaround to avoid me needing to re-write all the server side methods to not use nullables?
Many thanks,
Doug