I am using a webBrowser control to open PDF document in winforms, it works fine but when closing the ap开发者_StackOverflow社区plication I get sometimes an error : "The Instruction at "0x2d864aa2" referenced memory at "0x00000008". The memory could not be "read". Is there a solution for this problem?
Regards.
Believe it or not, yesterday I've been banging my head against this exact same problem and here's the solution I've found. Add the following to the FormClosed
event:
[DllImport("ole32.dll")]
private static extern void CoFreeUnusedLibraries();
private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
{
base.OnFormClosed(e);
webBrowser1.Visible = false;
while (webBrowser1.IsBusy)
{
Application.DoEvents();
}
webBrowser1.Dispose();
CoFreeUnusedLibraries();
}
Actually it seems there's a bug in Adobe Acrobat 9.x causing this exception.
精彩评论