Silverlight Cache Control: Using revision number in url for XAP causes HyperLink to crash SL App!

StackOverflow https://stackoverflow.com/questions/987413

Question

To make sure all our customers receive the latest Silverlight App, we are placing the new revision number on the url for XAP file as follows:

<param name="source" value="/ClientBin/ShoeboxViewer.xap?v=5" />

Problem is when we do this, all HyperLink controls (in the Silverlight App) that use relative URLs, throw an internal error when clicked. Here's the stack trace:

Unhandled Error in Silverlight 2 Application Specified argument was out of the range of valid values. Parameter name: baseUri at System.Uri..ctor(Uri baseUri, Uri relativeUri) at System.Windows.Controls.HyperlinkButton.GetAbsoluteUri() at System.Windows.Controls.HyperlinkButton.Navigate() at System.Windows.Controls.HyperlinkButton.OnClick() at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e) at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e) at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)

If I remove the querystring, it works fine.

Can anyone help?

Cheers, Ash.

Was it helpful?

Solution

Jacob is right - you might also want to look at this solution to fixup relative URLs.

OTHER TIPS

The problem is actually that HyperlinkButtons can't use relative urls. I ran into this just the other day. It's a hack, but I got it to work by adding a click handler to the HyperlinkButton and then calling HtmlPage.Navigate, passing in a uri marked as relative

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top