Monday, February 13, 2012

WCF Data Service: “Value cannot be null" exception while trying to select multiple columns in a $select query

Problem
You have a data service that have large number of column and you want to select only few columns but service trows

Error Stack Trace
at System.Data.Services.WebUtil.CheckArgumentNull[T](T value, String parameterName)




at System.Data.Services.Internal.ProjectedWrapper.set_PropertyNameList(String value)
at lambda_method(Closure , Shaper )
at System.Data.Common.Internal.Materialization.Coordinator`1.ReadNextElement(Shaper shaper)
at System.Data.Common.Internal.Materialization.Shaper`1.SimpleEnumerator.MoveNext()
at System.Data.Services.Internal.ProjectedWrapper.EnumeratorWrapper.MoveNext()
at System.Data.Services.DataService`1.SerializeResponseBody(RequestDescription description, IDataService dataService)
at System.Data.Services.DataService`1.HandleNonBatchRequest(RequestDescription description)
at System.Data.Services.DataService`1.HandleRequest()

Root Cause :-
By default WCF Data Service do not support more that 180 char in url string , probably it is asp.net setting
Workarounds
There are certain workarounds but I have not tried them , once tried i will update the post
  1. Configuring HTTPRuntime settings
    1. HttpRuntimeSection.MaxUrlLength Property
    2. HttpRuntimeSection.RelaxedUrlToFileSystemMapping Property
    3. HttpRuntimeSection.MaxRequestLength Property
  2. Configuring "Request Filtering" on server 
    1. http://www.bondigeek.com/blog/2011/05/31/dealing-with-long-querystrings-and-wcf-data-services/
Further References


at lambda_method(Closure , Shaper )
at System.Data.Common.Internal.Materialization.Coordinator`1.ReadNextElement(Shaper shaper)
at System.Data.Common.Internal.Materialization.Shaper`1.SimpleEnumerator.MoveNext()
at System.Data.Services.Internal.ProjectedWrapper.EnumeratorWrapper.MoveNext()
at System.Data.Services.DataService`1.SerializeResponseBody(RequestDescription description, IDataService dataService)
at System.Data.Services.DataService`1.HandleNonBatchRequest(RequestDescription description)
at System.Data.Services.DataService`1.HandleRequest()

No comments:

Post a Comment