tags:

views:

14

answers:

0

I am invoking the DataServiceContext methods through reflection.

I have introduced a partial class to generated Data Service Context class. The partial class has a method : GetCustomers

public partial class NorthwindDataSvcContext { Customer[] GetCustomers() { return this.Customers.ToArray(); } }

I invoke the above code using Reflection. I get the following exception.

System.NullReferenceException: Object reference not set to an instance of an object. at System.Data.Services.Client.QueryAsyncResult.CompletedRequest() at System.Data.Services.Client.QueryAsyncResult.Execute(MemoryStream requestContent) at System.Data.Services.Client.DataServiceRequest.Execute[TElement](DataServiceContext context, Uri requestUri) at System.Data.Services.Client.DataServiceQuery1.Execute() at System.Data.Services.Client.DataServiceQuery1.GetEnumerator() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) at ODataServiceProxy.AdventureWorksEntities1.GetCustomers()

I dont know why there is a null reference exception thrown for invoking the method through reflection.

Thanks