Why am I getting a NotSupportedException in WP7 Silveright using oDAta? - silverlight

I have a WCF Service set up on my web site with a service. I can access all of the data I am trying to obtain using a web browser. When I navigate around I can filter and get to any part of the data I need, so the feed seems to be set up correctly.
When I try to access this data using my auto-generated oData service reference I am running into an issue where it gives me a not supported exception as soon as I try to enumerate either the IQuerable or the DataServiceQuery.
Anyone know what I might be doing wrong that is getting me this NotSupportedException?
Notes: This is currently running locally. The web site is a .NET 4 app. I am using the OData Client Library for Windows Phone 7 series from here. When I run this code from a console application it works perfectly.

Are you running it asynchronously? Silverlight needs requires that requests are made asynchronously.

Related

"Calls to the web service will fail..." Once Again

Last year someone reported encountering this problem ("The Silverlight project you are about to debug uses web services. Calls to the web service will fail unless the silverlight project is hosted in and launched from the same web project that contains the web services.") and accepted the answer to "set the web project which hosts the Silverlight application to be your startup project."
I'm seeing the same message, but think the solution might have to be different. I am building in VS 2010 a Silverlight application to access the Google Weather API, with VB as the code-behind. The API will return a XML file with data for the specified city (ex., "http://www.google.com/ig/api?weather=london,england"). The Solution Explorer only shows my VB/Silverlight project ("GetWeather"), and the Project Properties dialog box shows the Startup Object as "GetWeather.App" -- the only choice. I'm trying to use a WebClient object to make the call and an XDocument object to parse the return. But I repeatedly get the above error message, with no other result. What am I doing wrong?
Thank you in advance!
I would add a simple Web project and configure it to host the Silverlight app. You'll need to host the app somewhere anyways, so why not create a stub ASP.NET application in your solution? The easiest way is to create a new Silverlight app solution selecting an ASP.NET web project as the host, and then copying your existing code to that solution. Then you should set the web project as the startup one. This should make debugging a lot easier.
Besides, do remember to configure the client access policy to enable cross-domain calls. Check out this article

Send simple data from wp7 to winforms application

I want to send simple data (geolocation data to be precise) from Windows Phone 7 application to a windows forms application and use it, as I'm a total beginner in this field I don't know which tools to use.
I searched about wcf services and tested this method but there's some issues: the data is sent from the phone application but isn't sent to the winforms application (guess something is missing)
If your know how to do this in a quick way, or have good tutorials I'll be thankful.
EDIT
I found this tutorial, it show how to connect directly wp7 application and desktop application without using sockets neither wcf service, I'm wondering if it is really works if the application isn't in localhost.
the like for the tutorial: wp7 tutorial
I had a similar problem and so I created a REST/JSON WCF service hosted in IIS with AppHarbor to provide the data. There's hundreds of ways to do it (Ruby/Heroku, etc..), but that particular one fits well within the Microsoft stack. I also needed to share route data and I used the WCF service to wrap the BingMaps services so that route computations are cached and shared. Considering that I had already created a local model, moving it out of my phone project into a service took less than a few hours (including the usual config hiccups, and forgetting to add the appharbor user to my bitbucket repo).
Consuming the service from WinForms (or any client) shouldn't be an issue as the service knows nothing about the client implementation.
Here's a tutorial from code project. REST WCF Service with JSON
I think you would need to implement some sort of server side solution which you could upload to on your Windows Phone and download from on your Windows Form application. This could be achieved using a WCF service which was connected to a server side database.
Another option would be to use sockets and communicate directly with your WinForms application. Check this tutorial on how to use basic sockets on WP7.

System Security Exception in Silverlight app making GET request

I am new to silverlight. I have been trying to patch up a silverlight app that makes a get request to some site over the net, say google. However, I keep getting the system.security exception again nd again. I read various other posts and what i gathered is that for these things to work u need to choose HOST APPLICATION IN A NEW WEBSITE option while creation of the project, i have done that, but still get the same exception. I downloaded the app from http://www.shinedraw.com/data-handling/flash-vs-silverlight-simple-http-post-request/ and ran it by clicking debug in VS2010, still it gave the same exception.
Please tell me what i am doing wrong, i know its cross domain issues, but dont know what else to do.
The second answer at this post - WebClient.DownloadStringAsync throwing Security Exception in Silverlight, I think, offers a workaround, but does this means there is no way to access such services from silverlight directly?? -
Experienced users please explain.
You cannot call a web service other than from your own domain directly from a Silverlight application. If you want to to this, you would have to install a cross-domain policy on the server that hosts the service. But you can always install a web service within your own web application (that hosts the Sivlerlight app) and call the other service from that service. It's one sercie call more but it works also with services you don't own.

Silverlight client never calls WCF Service

This one has me completed stumped. I have developed a silverlight application that calls back to WCF services ( it's a silverlight - basicHttpBinding)
The site works perfectly fine from my development machine, but when it is deployed to the developement server. The application is delivered with the XAP just fine, but it never attempts to talk to the service. I have a service call in the bootstrapper so it should be calling this when the client starts up. The services are healthy. They can be browsed to and show the standard WCF service display. We have been through the bindings many times and everything seems to be ok. I have added an extensive amount of error handling for displaying any errors, but on this dev server, no service calls and no errors are being raised.
Fiddler shows the page being loaded up, but my client never issues a call to the service. The service is in the same folder as the default.aspx which hosts the Silverlight client.
This is a Silverlight 3.0 app.
Anybody ever seen anything similar?
I will try to debug in three steps
Verify whether the hosted service on dev server is up or not, by hitting the service URL from your browser on your dev machine.
Make sure that ServiceReferences.ClientConfig consists ur hosted service URL and not dev machine service URL.
If still error occurs try to debug your application from visual studio by pointing the endpoint address to http://urserver/urservicename.svc
Also make sure you dont have have cross domain problems by using "silverlight spy" tool
Put a graphical display like "I made the call!" before the service invocation. just to be sure that your app is really trying to call the service...
So we could narrow the search to a communication problem. : )
Verify that there aren't any cross-domain rules stopping the app to make the call.
by the way, are you calling a WCF service from another domain?
Are you sure the silverlight app is loading at all? If you are making the service call in the boot strapper and the call breaks, I assume that will lead to just a blank page. If you are seeing just a blank page, then perhaps there is something wrong with the .xap mime type issued from the server. Here is some more info on that:
http://learn.iis.net/page.aspx/262/configuring-iis-for-silverlight-applications/

Deploying a Silverlight Application with built-in ASMX WebService to IIS

I've got a Silverlight application which uses a built-in .ASMX WebService to access a SQL database and run some queries. Everything runs without any hitches on my Development machine.
I'm trying to deploy the application to IIS 6 and I'm having some issues.
The Silverlight application itself seems to run fine, however the Web Service does not. I get an unhandled exception error that says [Async_ExceptionOcurred] as soon as the page loads (when the page loads I'm making some Async WebService method calls).
I think this is an issue with the Web Service but I don't know what the problem is. I tried setting the WebService namespace to my URL, but that didn't work. I've tried messing with the SQL connection string in my Web Config but that also affects nothing.
One thing to note is that my IIS Virtual Directory only contains my SilverlightApp.Web folder. I know that the other folder that's part of the application contains a .ClientSettings file for the WebService, but I think this is embedded into the .xap.
Can anyone shed any light on this?
The most likely thing that's happening:
Your webservice proxy on the client is using the address of the web service it was built against: ("http://localhost...").
Things to do:
Use fiddler to confirm this is the issue. It will show you where the proxy is making the call to.
Use the overloaded constructor for the web service and specify a URI. Consider using id/deffing for debug/release. This will overwrite the settings in the client.config.
Create another endpoint in the client config for the release build (Shawn's article here) and select one or the other (again using if/defs).
There are other options as well (looking at the URI and building up the service adress)... but that's the general idea.
hth,
Erik

Resources