我正在尝试编写一个MVC3应用程序,它将检索本地存储在服务器上的图像。在网页上显示它们,让用户标记图像以供日后查看。当我说标签时,我的意思是实际修改标签"标签"服务器上文件的属性。当我运行下面的代码时,我得到以下错误:"调用线程必须是STA,因为许多UI组件需要这个"在"图像imageToTag = new Image();线。请帮忙!我已经被困在这里大约3天了,我从未做过多次多线程。
Image imageToTag = new Image();
BitmapImage myBitmapImage = new BitmapImage();
var root = @"C:\Images\";
imageURLProcessed = Path.GetFullPath(@imageURLProcessed);
// BitmapImage.UriSource must be in a BeginInit/EndInit block
myBitmapImage.BeginInit();
if (!imageURLProcessed.StartsWith(root))
{
// Ensure that we are serving file only inside the root folder
// and block requests outside like "../web.config"
throw new HttpException(403, "Forbidden");
}
myBitmapImage.UriSource = new Uri(@imageURLProcessed);
myBitmapImage.EndInit();
imageToTag.Source = myBitmapImage;
imageToTag.Tag = tags;