Jeff Sanders Technical Blog

I am a Microsoft employee that has worked on all aspects of the Web Stack for a long time. I hope these blogs are useful to you! Use this information at your own risk.


<< Go Back

You Have A Net Control Hosted In Internet Explorer 8 And It Restarts A Tab In Internet Explorer

- 01 Apr 2009

<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /><p style="MARGIN: 0in 0in 10pt" class=MsoNormal>Message: This Tab Has Been Recovered </p> <p style="MARGIN: 0in 0in 10pt" class=MsoNormal>Previous versions of IE are fine.</p> <p style="MARGIN: 0in 0in 10pt" class=MsoNormal>If the control implements IObjectSafety or other interfaces improperly, this could cause this message.

  The reasons for this include that you did not implement the IObjectSafety Interface properly.  You must use the PreserveSig attribute in this interface definition:</font></p>

<span style="FONT-SIZE: 10pt; mso-ansi-language: EN" lang=EN>[ComImport]</span>
[Guid("CB5BDC81-93C1-11CF-8F20-00805F2CD064")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IObjectSafety
{
&nbsp;&nbsp; [PreserveSig]
&nbsp;&nbsp; int GetInterfaceSafetyOptions(ref Guid riid, out int pdwSupportedOptions, out int pdwEnabledOptions);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp; [PreserveSig]
&nbsp;&nbsp; int SetInterfaceSafetyOptions(ref Guid riid, int dwOptionSetMask, int dwEnabledOptions);
}

<font size=3 face=Calibri>The reason your control may work in IE7 fine and stop working in IE8 without the PreserveSig attribute is because the older code is compiled different.&nbsp; IE8 is using Stack objects and indexed on ESP.&nbsp; The incorrect method definition for the interface unbalances the stack and ESP is off and this causes the underlying AV that results in this message.</font>

<font size=3 face=Calibri>Fix your code to implement the Interface correctly and this will fix the problem.</font>

`</p>

Let me know if you find this useful!

</font>`</span>

<< Go Back