Silverlight - how get public photos

Topics: User Forum
May 4, 2011 at 7:58 PM


I need in my SLV app only some public photos for demonstration. I use simple authentization with ApiKey - need I token? I use some source from example:
this._flickr = new FlickrNet.Flickr(ApiKey);
FlickrNet.PhotoSearchOptions searchOptions = new FlickrNet.PhotoSearchOptions();     
searchOptions.Tags = "microsoft";      
this._flickr.PhotosSearchAsync(searchOptions, PhotosSearchAsync_Result);

When I get result collection, I create my object and Image:
item.SpecificImage = new BitmapImage(new Uri(photo.SmallUrl)); 

But this make exception
{System.UnauthorizedAccessException: Invalid cross-thread access.   v MS.Internal.XcpImports.CheckThread()   v System.Windows.DependencyObject..ctor(UInt32 nativeTypeIndex, IntPtr constructDO)   v System.Windows.Media.Imaging.BitmapImage..ctor(Uri uriSource)   v ImageViewerApp.MainPage.PhotosSearchAsync_Result(FlickrResult`1 result)   v FlickrNet.Flickr.<>c__DisplayClass13`1.<DoGetResponseAsync>b__12(IAsyncResult responseAsyncResult)}

I think this is while image is getting in other thread, that is not authentocated. How can I solve this?

May 4, 2011 at 9:25 PM

Well going by the error this has something to do with the Bitmap line, and nothing to do with anything to do with Flickr.

Try googling for "Bitmap Silverlight Invalid Cross Thread Access".


May 5, 2011 at 2:46 PM

You're right, thank you. The code was in another thread than the UI.