Generally speaking, I've had decent luck upgrading my beta 1 applications to beta 2. The one exception to that was the Twemes client I wrote, which currently resides at http://www.toysfortweets.com. The changes made to the cross-domain policy seemed simple enough - include a "headers" attribute when using HttpWebRequest. Unfortunately, *nothing* I was doing seemed to help.
This is one of those situations where I don't have control over the target domain name, but the people who run it were kind enough to place a Flash policy file up there for me. I didn't want to keep asking them to make changes, so I placed the files on another domain we have control of, and worked from that. I installed the Web Development Helper recommended in this great post by Tim Heuer. This gave total visibility into what was happening when I loaded the page, and there were a couple of problems. Eventually I got the problems fixed, but still no love.
The site loaded the application, the application called out to check for the Silverlight cross-domain policy file, which returned a 406 (Not Acceptable), then called out to check for the Flash cross-domain policy which returned a 200 (OK). Having that, the app called out for the RSS feed, which returned 200, and 19K of data. After that, silence. The callback function was not executing. This leads me to believe there may be a quirk in Silverlight when the Flash cross-domain policy file is in play. Silverlight took the file as OK, but it didn't recognize the data needed to make the app go had come back. I tried several variations of the file based on different posts I found on the Silverlight.net forums, but nothing worked.
Finally, out of frustration, I created a simple version of the project that was still failing to execute the callback and sent it off to Tim Heuer for a more experienced set of eyes. He didn't have any insight as to why HttpWebRequest was not executing the callback, but suggested I use WebClient instead. There is an older post on Tim's site describing how to call web services. The example code was a big help in changing over to WebClient from HttpWebRequest.
The Flash cross-domain policy on the target domain currently looks like this:
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>
The code to call out for the file now looks like this:
WebClient rest = new WebClient();
rest.DownloadStringCompleted += new DownloadStringCompletedEventHandler(rest_DownloadStringCompleted);
rest.DownloadStringAsync(new Uri("RSS FILE NAME"));
This returns the data as e.Result in the DownloadStringCompleted event handler:
XDocument doc = XDocument.Parse(e.Result);
This now means I can use the information in "doc":
var items = from g in doc.Descendants("item")
select new
{
title = g.Element("title").Value,
description = g.Element("description").Value,
pubDate = g.Element("pubDate").Value,
guid = g.Element("guid").Value,
link = g.Element("link").Value,
};
Once the data was organized, I populate arrays based on the data I need. The reason why I did it this way is because the app displays random posts, so it's easy to reach in and grab an element out of the array.
foreach (var item in items)
{
i++;
rssDescriptions[i] = item.description;
rssLinks[i] = item.link;
rssPubDates[i] = item.pubDate;
}
I was going to use a multidimensional array, but I'm not tracking that much data, so it's easier to keep track of this way. So now whenever a new post is detected in the RSS, the app will display the first post, then generate 4 random numbers to grab other posts out of the feed for display.
Entries (RSS)
June 13th, 2008 at 9:23 am
jeff–i think i figured out the problem. adobe changed the format of their flash policy file as well and thus beta 2 is actually already aware of that…in the silverlight sdk docs has the supported format
June 17th, 2008 at 2:22 pm
[...] to Beta 2 … that’s what, 3 major fixes in 3 days… somebody has a lot more time than me
Toys for Tweets, Take (beta) 2… Jeff Paries pinged me that he has his Twemes client upgraded to Beta 2, and details some issues he [...]