Hi there,

We have an IE AddOn which works fine in IE6. The functionality of the Plugin also works well in IE7 but it starts crashing IE7 whenever we click on any drop down or try to open links in new tab.

IE7 crashes with the following information:

"Unhandled exception at 0x085c8e7c in iexplore.exe: 0xC0000005: Access violation writing location 0xad186a91."

We are not able to debug because the error is out of the code. I mean error is initiated before the debug point. I get this error when we debug the code. Initially it just displays to debug or close IE7.

Here are our views regarding this bug:

1) We have used Microsoft.mshhtml.dll and Interop.SHDocVw.dll in this application. Initially we thought that it is caused due to incompatibility with IE7 but we figured out that we are using the latest version of Microsoft.mshtml.dll

2) Then we figured out this bug can be caused due to TABs because each tab initializes the plugin and its something with the Tabs. But we did not found any helpful resource on internet.

Below is the code where we think the error can be. We can also give you the entire code if you need.

private uint ShowContextMenu(object pTarget, object pElement, tagPOINT pPoint) {

IntPtr xWnd = IntPtr.Zero;

IOleWindow xOleWindow = pTarget as IOleWindow;

Debug.Assert(xOleWindow != null, "Can't get IOleWindow interface from target.");

xOleWindow.GetWindow(out xWnd);

Debug.Assert(xWnd != IntPtr.Zero, "Can't get HWND from target IOleWindow.");



SubclassingWindow xSubClass = new SubclassingWindow(this);


//WndProcDelegate xDelegate = new WndProcDelegate(SubWndProcDelegate);

//IntPtr xOldWndProc = IntPtr.Zero;

//xOldWndProc = new IntPtr(GetWindowLong(xWnd, -4));

//SetWindowLong(xWnd, -4, Marshal.GetFunctionPointerForDelegate(xDelegate).ToInt32());


//FWndProc =

// (WndProcDelegate) Marshal.GetDelegateForFunctionPointer(xOldWndProc, typeof (WndProcDelegate));


int xCmd =

TrackPopupMenu(FContextMenu, (uint) (0x0000L | 0x0002L | 0x0100L), pPoint.X, pPoint.Y, 0, xWnd,


//SetWindowLong(xWnd, -4, xOldWndProc.ToInt32());





FDictionariesMenu = IntPtr.Zero;


if (xCmd == 0) {

return (ResultCom.S_OK);

} else if (xCmd == FLookupId) {


tagRECT xRect = new tagRECT();

GetWindowRect(xWnd, out xRect);

Rectangle xRectangle = (Rectangle) xRect;


Point xClient = new Point(pPoint.X - xRect.Left, pPoint.Y - xRect.Top);


Translate(pPoint, xClient, pElement);


} else if (FDictionaryById.ContainsKey((uint) xCmd)) {


ClueDictionaries.SelectedDictionary = FDictionaryById[(uint) xCmd];

} else {

SendMessage(xWnd, (uint) WindowsMessages.WM_COMMAND, new IntPtr(xCmd), IntPtr.Zero);


return (ResultCom.S_OK);


Please help. it is very urgent.

Thank you all in advance for replying. you can reach me on yahoo messenger. My Id is nemesh_singh.

Nemesh Smile

Re: Internet Explorer Extension Development Plugin Works fine in IE6 but crashes in IE7 (whenever a drop down is selected or download is opened in a new TAB)



You are destoying IE's context menu before it is displayed


You only need to destroy your custom menu extension to prevent them from being drawn again.