0

I am trying to write an MVC3 application that will retrieve images that are stored locally on the server. Display them on the webpage and let the user tag images for later review. When I say tag, I mean actually modify the "Tag" property of the file on the server. When I run the code below I get the following error: "The calling thread must be STA, because many UI components require this" on the "Image imageToTag = new Image(); line. Please help! I've been stuck on this for about 3 days and I have never done much multithreading.

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;

1 Answer 1

0

But an answer to your question: http://social.msdn.microsoft.com/Forums/en-us/csharpgeneral/thread/f5e83bc0-b523-45d2-b77c-b1702124869c

http://msdn.microsoft.com/en-us/library/system.drawing.image.setpropertyitem.aspx

1
  • this is a poor answer, since there is no Property corresponding to tags. The properties you linked seem to be responsible for meta data only, like aperture or GPS loc Oct 15, 2012 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.