Skip to main content

Microsoft Silverlight

Answered Question DataServicesQuery in ViewModel gives Exception -- "access is denied"RSS Feed

(0)

jimijani1982
jimijani...

Member

Member

3 points

8 Posts

DataServicesQuery in ViewModel gives Exception -- "access is denied"

Hi , i am using Silverlight navigation framework , i am using viewmodel for each page ( Navigation page ) . In the viewmodel this line , query.BeginExecute ( query is an instance of DataServiceQuery) throws invalidoperationexception with message saying access is denied . NOTE :I am instancing the viewmodel class in the codebehind class of the page( Navigation page ) and this is my gut feeling that this is the problem , here is the complete code of view model. public class HomeViewModel { public HomeViewModel() { V3C_DataBaseEntities entities = new V3C_DataBaseEntities(new Uri("http://localhost:59474/V3CDataService.svc/", UriKind.Absolute)); var r = from c in entities.ChatRoomSet select c; DataServiceQuery query = (DataServiceQuery)r; // now below line gets crashed!!!!!!!!!!!!!!! query.BeginExecute(new AsyncCallback(LoadRooms), query); } private static void LoadRooms(IAsyncResult asyncResult) { DataServiceQuery query = (DataServiceQuery)asyncResult.AsyncState; List temp = query.EndExecute(asyncResult).ToList(); } thanks Jamal.

philip.beadle
philip.b...

Member

Member

500 points

104 Posts

Answered Question

Re: DataServicesQuery in ViewModel gives Exception -- "access is denied"

First thing, that code should go in your Model, not the ViewModel.

Second it looks to me like you need a cross domain access file setup as you are using absolute urls.  That should solve your access is denied issue.

Philip Beadle (DotNetNuke Trustee)

My Blog

My DNN Blog

(If this has answered your question, Mark as Answer)

jimijani1982
jimijani...

Member

Member

3 points

8 Posts

Answered Question

Re: Re: DataServicesQuery in ViewModel gives Exception -- "access is denied"

thanks philips , the problem got resolved , actually my web project was not the startup project infact the silverlight project was the startup project thus the url had file system path and that was causing "access denied". thanks Jamal.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities