Skip to main content

Answered Question SL2B2 Read from EF not workingRSS Feed

(0)

NJP
NJP

Member

Member

13 points

4 Posts

SL2B2 Read from EF not working

Hi I am trying the following sample code:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Animation;

using System.Windows.Shapes;

using System.Data.Services.Client;

using NitishTestModel;

using System.Collections;

namespace SilverlightApplication1

{

public partial class Page : UserControl

{

public Page()

{

InitializeComponent();

}

private void btnClick_Click(object sender, RoutedEventArgs e)

{

Entities ctx = new Entities(new Uri("http://localhost:49968/WebDataService1.svc"));

var qry = from l in ctx.Link2

where l.ID==1 select l;

// Cast the query to a DataServiceQuery

DataServiceQuery<Link2> Link2Query = (DataServiceQuery<Link2>)qry;

// Start the execution

Link2Query.BeginExecute(new AsyncCallback(OnLoadComplete),

Link2Query);

}

void OnLoadComplete(IAsyncResult result)

{

// Get a reference to the Query

DataServiceQuery<Link2> Link2Query = (DataServiceQuery<Link2>)result.AsyncState;

// Get ther esults and add them to the collection

List<Link2> _lnks = Link2Query.EndExecute(result).ToList();

}

 

 

}

}

but i get the following error:

System.InvalidOperationException occurred
  Message="Failed to Invoke: callOpen."
  StackTrace:
       at System.Windows.Browser.ScriptObject.Invoke(String name, Object[] args)
       at System.Data.Services.Http.ScriptObjectUtility.CallOpen(ScriptObject request, String method, String uri)
       at System.Data.Services.Http.HttpWebRequest.ScriptXmlHttpRequest.Open(Boolean async, String url, String method, Action OnReadyStateChange)
       at System.Data.Services.Http.HttpWebRequest.InvokeRequest(Boolean async)
       at System.Data.Services.Http.HttpWebRequest.BeginGetResponse(AsyncCallback callback, Object state)
       at System.Data.Services.Client.QueryAsyncResult.BeginExecute(MemoryStream requestContent)
       at System.Data.Services.Client.DataServiceRequest.BeginExecute(Object source, DataServiceContext context, AsyncCallback callback, Object state)
       at System.Data.Services.Client.DataServiceQuery`1.BeginExecute(AsyncCallback callback, Object state)
       at SilverlightApplication1.Page.btnClick_Click(Object sender, RoutedEventArgs e)
  InnerException:

Thanks in Advance,

NJ

NJP
NJP

Member

Member

13 points

4 Posts

Answered Question

Re: SL2B2 Read from EF not working

Figured it. It was because of this :-

"Unfortunately, due to work arounds required for other aspects of Data Services functionality, cross-domain access is not supported in the Data Services client included in Silverlight Beta 2. We're working to sort out the issue for the RTM release.

 

Pablo Castro
Software Architect
Microsoft Corporation
http://blogs.msdn.com/pablo"

Pablo Castro's post from the Astoria forum

dav_cup
dav_cup

Member

Member

6 points

6 Posts

Re: SL2B2 Read from EF not working

NJP:

"Unfortunately, due to work arounds required for other aspects of Data Services functionality, cross-domain access is not supported in the Data Services client included in Silverlight Beta 2. We're working to sort out the issue for the RTM release.

Hi, have you solved for the RC0?

Thanks

MCT
Davide Cuppone

MisterFantastic
MisterFa...

Member

Member

37 points

21 Posts

Re: Re: SL2B2 Read from EF not working

 Hi,

This does not seems to be a cross domain problem . Are you having both of your dataservice and webapplication in sam eporject or different project ? 

Thanks,

Thani

Tao of Jeet Kune Do

ionutz
ionutz

Member

Member

4 points

3 Posts

Re: SL2B2 Read from EF not working

 I have the same problem. I think it's because my dataservice and webapplication are in different projects. It seams to me that it is a cross domain problem. Please help.

Thanks.

JHN

dav_cup
dav_cup

Member

Member

6 points

6 Posts

Re: SL2B2 Read from EF not working

Having dataservice and webapplication in two different projects equival to a crossdomain.

I read somewhere, sorry I don't have the link right now, that silverlight use the XMLHttpRequest to access the dataservice so has the same limit of Ajax. You have to use a server side proxy.

 PS this is the link: http://blogs.msdn.com/phaniraj/archive/2008/10/21/accessing-cross-domain-ado-net-data-services-from-the-silverlight-client-library.aspx

MCT
Davide Cuppone

ionutz
ionutz

Member

Member

4 points

3 Posts

Re: SL2B2 Read from EF not working

 Thanks for the link. I have followed that tutorial but I still have a problem : AsyncCallback never returns a result and the CrossDomainHandler class crashes of NullReferenceException because it doesn't receive anything when GetResponseStream() is called. This cross-domain problem becomes a real pain to me. Please help.

JHN

JosephBrittoE
JosephBr...

Member

Member

4 points

2 Posts

Re: SL2B2 Read from EF not working

Consuming  ADO.NET Services into Silverlight Application


Entities context =
new
NorthwindEntities(new Uri(HtmlPage.Document.DocumentUri, "Northwind.svc"));

http://msmvps.com/blogs/theproblemsolver/archive/2009/01/06/consuming-an-ado-net-data-service-from-silverlight.aspx

  • Unanswered Question
  • Answered Question
  • Announcement