Monday, December 3, 2012

Images not displayed in silverlight when app is run

Images not displayed in silverlight when app is run

I'm trying to display an image within a Silverlight application but the image does not display when the application is run. When creating the project within Visual Studio I chose the "Automatically generate a test page to host Silverlight at build time" option.

Complete code as an example:

<UserControl x:Class="SilverlightApplication3.Page"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"      Width="400" Height="300">     <StackPanel>                 <Image Source="http://www.beachtownpress.com/db5/00415/beachtownpress.com/_uimages/beach7.jpg" />     </StackPanel> </UserControl> 

The application appears perfectly within Visual Studio, but when I run the application, the image does not display. Any ideas?

Answers & Comments...

Answer: 1

Mmm...

Take a look to this doc:

http://msdn.microsoft.com/en-us/library/system.windows.controls.image.source(VS.95).aspx

I think the main issue is that you are making a cross domain call, just and advice: download fiddler, there you will check if the server where you are requesting the data allows cross domain calls (just give a try, load an image from flckr and see what happens).

One solution, could be to use tunneling on the server side (a custom http hanlder on your domain, that grabs the image from a remote server and redirects it to your SL petition).

HTH Braulio

by : Brauliohttp://stackoverflow.com/users/76922

Answer: 2

Your example is absolutely working. I've just tried it.

May be the problem is in the network?

You can debug network communications via Fiddler.

by : Alexander K.http://stackoverflow.com/users/108096

Answer: 3

While cross-domain URL access is allowed for the Image control, cross-scheme access is not. When running using the automatically generated test page, it will run from your local drive (I guess that would indirectly run in under the FILE protocol), so it will not be allowed to cross-scheme to the HTTP protocol. What you should do is to have the page containing your Silverlight control run under http://localhost, that should do the trick.

Reference: URL Access Restrictions in Silverlight

Alternatively, at your Silverlight Project (not the web project) properties, at Debug pane, select to run it as OOB application for testing

by : Amryhttp://stackoverflow.com/users/321360

Answer: 4

I have the exact same problem. It freaked me out when I ran the application from EXPRESSION BLEND 3, but it doesn't WORK from VS 2008 .... I'm looking for the answer right now ....

~~~EDIT~~~~ I found the solution. Simply go to the Solution and ADD a new ASP.NET Web application ... It should work... It did for me ...

by : Cosminhttp://stackoverflow.com/users/366098

Answer: 5

This is a real show stopper!!!. At least webservice calls are still possible if you install some stupid file on the webserver of the webservice. Maybe this helps: install a clientaccesspolicy.xml on the webserver for images. http://msdn.microsoft.com/en-us/library/cc645032%28VS.95%29.aspx

by : yonexbathttp://stackoverflow.com/users/288291




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog