silverlight - An exception when downloading an image from url to siverlight c# project -


i searched how make gadget windows 7/vista programmatically in c# , @ end downloaded visual studio solution called silverlightgadgetdebugger:

the purpose of silverlightgadgetdebugger project act debug session starter silverlight gadget. though console application project, produces no output. instead, whenever project started invoke sidebarsandboxstarter.exe file. application receives current solution path command line parameter. uses information connect visual studio has specified solution opened. sidebarsandboxstarter attach debugger instance of visual studio windows sidebar process (sidebar.exe). if process not started, start it.

i added image silverlight control, i'm trying image url :

http://lunaf.com/images/moon-phases/lunar_phase_20.jpg 

i searched how image , tried code :

private void downloadimage() {         string imagepath = "http://lunaf.com/images/moon-phases/lunar_phase_20.jpg";         webclient client = new webclient();         client.openreadcompleted += client_openreadcompleted;          if (imagepath.indexof("http") < 0)         {             string url = system.windows.browser.htmlpage.document.documenturi.absoluteuri;             imagepath = url.substring(0, url.lastindexof('/')) + "/" + imagepath;         }          client.openreadasync(new uri(imagepath, urikind.relativeorabsolute), imagepath);      }      void client_openreadcompleted(object sender, openreadcompletedeventargs e)     {         try         {             bitmapimage imagetoload = new bitmapimage();             imagetoload.setsource(e.result stream);//here exception             image1.source = imagetoload;         }         catch (exception ex)         { } } 

i exception , message (ex.message) :

an exception occurred during operation, making result invalid. check innerexception exception details.

and inner exception :

{system.security.securityexception ---> system.security.securityexception: security error.    @ system.net.browser.browserhttpwebrequest.internalendgetresponse(iasyncresult asyncresult)    @ system.net.browser.browserhttpwebrequest.<>c__displayclassa.<endgetresponse>b__9(object sendstate)    @ system.net.browser.asynchelper.<>c__displayclass4.<beginonui>b__0(object sendstate)    --- end of inner exception stack trace ---    @ system.net.browser.asynchelper.beginonui(sendorpostcallback beginmethod, object state)    @ system.net.browser.browserhttpwebrequest.endgetresponse(iasyncresult asyncresult)    @ system.net.webclient.getwebresponse(webrequest request, iasyncresult result)    @ system.net.webclient.openreadasynccallback(iasyncresult result)} 

how fix ??


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -