This is a migrated thread and some comments may be shown as answers.

Invalid Image data - object is in use elsewhere

3 Answers 387 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Anula
Top achievements
Rank 1
Anula asked on 30 May 2018, 06:48 AM

Hello I have a following problem - in my web app I am using an html 5 report viewer with telerik reporting and from time to time I am encountering a following problem - picturebox control is not being loaded with image data. Attached is a screenshot with a problem.

I am loading image data as base:

     [code]var bytes = Convert.FromBase64String(base64String);
            using (var ms = new MemoryStream(bytes))
            {
                pbLogo.Value = Image.FromStream(ms);
            }[/code]

 

I tried to search for similara problems, but none of the resolutions worked out.


3 Answers, 1 is accepted

Sort by
0
Squall
Top achievements
Rank 1
answered on 01 Jun 2018, 02:05 PM

The error from this thread looks similar - https://social.msdn.microsoft.com/Forums/windows/en-US/2ee73705-d2a1-4f92-bda5-523fe1e4cd77/the-object-is-currently-in-use-elsewhere?forum=winforms

Is this the same issue?

0
Werdna
Top achievements
Rank 1
answered on 31 Jan 2019, 11:52 PM

Anula, did you ever find a solution for this problem?  I'm having the same issue.

Thanks

0
Silviya
Telerik team
answered on 05 Feb 2019, 05:23 PM
Hi Andrew,

There's a lock inside GDI+ that prevents two threads from accessing a bitmap at the same time. Please check the following articles on the same topic:
https://stackoverflow.com/questions/12355631/object-is-currently-in-use-elsewhere-exception-when-setting-image-in-picturebo
https://stackoverflow.com/questions/1851292/invalidoperationexception-object-is-currently-in-use-elsewhere
https://blogs.msmvps.com/peterritchie/2008/01/28/quot-object-is-currently-in-use-elsewhere-quot-error/

Regards,
Silviya
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Anula
Top achievements
Rank 1
Answers by
Squall
Top achievements
Rank 1
Werdna
Top achievements
Rank 1
Silviya
Telerik team
Share this question
or