Skip to main content
Home Forums Silverlight Programming Report a Silverlight Bug DataServicesQuery in ViewModel gives Exception -- "access is denied"
2 replies. Latest Post by jimijani1982 on September 9, 2009.
(0)
jimijani...
Member
3 points
8 Posts
09-06-2009 2:37 PM |
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.b...
500 points
104 Posts
09-08-2009 5:10 AM |
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.
09-09-2009 5:59 AM |
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.