获取图像,未经授权的访问异常错误

时间:2013-01-31 16:13:11

标签: c# windows-phone-7

我正在获取json数据,其中有一个链接可以再次获取图像

例如:

{"status":"403","message":"Not Authorized","image":"http:\/\/abc.com\/images\/1.jpg"}

状态,消息n图像被完全检索,因为我在文本框中显示了值。

此外我想显示图像,所以我这样做:

public string link = ClassName.variableName;

link现在保留值http//abc.com/images/1.jpg。我在文本框中显示了它的值并且很好。所以我走得更远:

BitMapImage MyImage = new BitMapImage( new Uri (link, UriKind.RelativeOrAbsolute));

image1.source = MyImage;

但是当我运行它时显示错误“UnAuthorized access exception unhandled”。为了交叉检查,我打开了一个新项目而不是获取数据,我直接提供了一个到图像源的链接,并显示了图像。

BitMapImage MyImage = new BitMapImage( new Uri ("http//abc.com/images/1.jpg", UriKind.RelativeOrAbsolute));

image1.source = MyImage;

这里工作正常。显示图像。

1 个答案:

答案 0 :(得分:0)

我没有使用Deployment.Current.Dispatcher.BeginInvoke(()=>现在它工作正常。