locked
DataServiceContext : Throws NullReferenceException RRS feed

  • Question

  • I am having this problem where by calling any method on the DataServiceCOntex throws Null Reference exception. Following is the stack trace:

    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.DataServiceQuery`1.Execute()
       at System.Data.Services.Client.DataServiceQuery`1.GetEnumerator()
       at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
       at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
       at ODataServiceProxy.AdventureWorksEntities1.GetCustomers()

    My code is as follows :

    AdventureWorksModel.

     

    AdventureWorksEntities1 ctxt = new AdventureWorksModel.AdventureWorksEntities1(new Uri(http://venknar-laptop:8081/AdventureODataSvc.svc/));
    AdventureWorksModel.
    Customer[] sampleCust = ctxt.Customers.ToArray();

    The above code works fine in a windows console app. But when its called from IIS hosted web service it fails. I tried setting the Credentials also. It did not help.

    Note : I am calling the actual method (GetCustomers) through reflection.

    Thanks

     

    Tuesday, September 7, 2010 6:11 PM

All replies

  • Hi Venki,

    I can successfully access the service via IE.  How is the problem now?

    Thanks
    Pam

    Thursday, September 9, 2010 9:03 AM
  • Hi,

     

    Could you please tell us how is the problem now?  

     

    Good day!

     

     

    Best Regards,
    Lingzhi Sun

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, September 17, 2010 1:33 AM
    Moderator