Click here to Skip to main content
15,910,471 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi all,

I have an exception like this:

Here are my code

MIDL
CPictureControl m_textImage;

m_textImage.Load(data.data1->GetData(), 
data.data1->GetSize());
Bitmap img(m_textImage.m_pStream, TRUE);
			Bitmap* pThumbnail = static_cast<Bitmap*>(img.GetThumbnailImage(85, 95, NULL, NULL));				
			// attach the thumbnail bitmap handle to an CBitmap object
			pThumbnail->GetHBITMAP(NULL, &hBmp);
			pImage = new CBitmap();		 
			pImage->Attach(hBmp);
			cImage->Add(pImage,pImage);
			delete pThumbnail;
			delete pImage;


In my code cImage is CImageList

But when I run, some time error happens at: gdiplusbitmap.h

MIDL
inline
Image::~Image()
{
    DllExports::GdipDisposeImage(nativeImage);//Error here
}


Error Message is: An unhandled exception of type 'System.AccessViolationException' occurred in Test.exe

Additional information:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt

It happens randomly and not very often. I don't know how to handle it.

Please help me.
Thanks,
-------------------------------------------------
[Update]

I already tried to delete pImage before pThumnail but nothing happen
Posted
Updated 7-Apr-11 16:09pm
v2
Comments
CPallini 7-Apr-11 4:18am    
Probably has nothing to do with your issue, anyway I would delete pImage before pThumbnail.
Lương Thông Đạt 7-Apr-11 4:53am    
I try to delete pImage before pThumbnail but nothing happen :)
I think pImage is deleted before GdipDisposeImage() run but I don't know how to stop it

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900