I making simple silverlight application.
I need to access and use an image from localhost,
I write down my code like this
Book4.Source = new BitmapImage(new Uri(“http://localhost/test/book2.png”, UriKind.Absolute));
It doesn’t make any errors, but It can’t load any image.
//P.S. I didn’t use asp. It is OOB app.
* EDITED: To include additional content for the question.
public void changeValue_book()
{
if (empty_book[3] == true && book_index == 3)
{
empty_book[3] = false;
Book4.Visibility = Visibility.Visible;
Book3.Visibility = Visibility.Visible;
Book3.Source = null;
Book3.Source = new BitmapImage(new Uri("http://localhost/test/book1.png", UriKind.Absolute));
//Book3.Source = new BitmapImage(new Uri("Resource/책1.png", UriKind.Relative));
}
else if (empty_book[4] == true && book_index == 4)
{
empty_book[4] = false;
Book5.Visibility = Visibility.Visible;
Book4.Visibility = Visibility.Visible;
Book4.Source = new BitmapImage(new Uri("http://localhost/test/book2.png", UriKind.Absolute));
}
else if (empty_book[5] == true && book_index == 5)
{
}
}
If you’re able to access the expected image from your web browser when you navigate to http://localhost/test/book2.png then try the following:
EDITED
If you’re images reside on http://localhost/test/yourimagename.png, but your Silverlight application is hosted within an https:// or from the Filesystem you will not be able to load the images at all. The Silverlight Image class and MediaElement class for progressive downloads (media, images, ASX, etc.) are not allowed Cross-scheme access.
Please see this link for more details:
http://msdn.microsoft.com/en-us/library/cc189008(v=vs.95).aspx