c# - 获取图片,未授权访问异常错误

标签 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;

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

最佳答案

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

关于c# - 获取图片,未授权访问异常错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14630179/

相关文章:

c# - 如何应用检查只选择简单的字符串而忽略包含日期的字符串?

c# - 无法将 "obj\Debug\Program.exe"复制到 "bin\Debug\Program.exe"。超过重试次数 10。失败

windows-phone-7 - Windows Phone 7 中的启动时间

.net - ScrollViewer 中的列表框

.net - 发音识别 - 语音 API 或算法

c# - 在 Xamarin 中,如何仅更改按钮的背景颜色 1 秒钟,然后再将其恢复为原始颜色?

c# - 重构函数,使其为 O(N)

windows-phone-7 - WP7音频/视频文件选择器

c# - 7 位 Julian 日期到普通日历日期

c# - 如何在 Windows Phone 7 中以编程方式检索下载的文件?