Fatalexecutionengineerror was detected

Hi

I am trying to save the chart(MS chart control 6.0) as an image(bitmap) file. Its working fine in Visual Studio 2003 but when I try to run the same program in VS 2005 the following error is thrown up at runtime.

Fatalexecutionengineerror was detected

The runtime has encountered a fatal error. The address of the error was at 0x7a005c3d, on thread 0xfdc. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

Here is the sample code that i am working with.

PrivateSub Button1_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles Button1.Click

Dim xAs IDataObject

Dim imgAs Bitmap

Chart1.EditCopy()

x = Clipboard.GetDataObject() ********** the error comes over here

img = x.GetData(DataFormats.Bitmap,True)

img.Save("c:\img1.bmp")

EndSub

Can anyone help me on this.

or

Is there any other way that I can save the chart as an image file?

Thanks

[2019 byte] By [gkrups] at [2007-12-28]