Search code examples
c#cookiesazuredllimportieframe.dll

DllImport entry point for Interop function not found in ieframe.dll running under Azure


In my C# app that's running under Azure, I need to use Interop / DllImport to call 'IEGetProtectedModeCookie' in ieframe.dll

Here's the signature:

  [DllImport("ieframe.dll", CharSet = CharSet.Unicode, EntryPoint = "IEGetProtectedModeCookie", SetLastError = true)]
  public static extern int IEGetProtectedModeCookie(String url, String cookieName, StringBuilder cookieData, ref int size, uint flag);

I've added ieframe.dll to my project's bin directory, and I have a reference to SHDocVw that generates the Debug or Retail Interop.SHDocVw.dll file in my obj directory.

When I test this on my dev box, everything works fine, but when I deploy to Azure, I'm getting the following runtime error:

System.EntryPointNotFoundException: Unable to find an entry point named 'IEGetProtectedModeCookie' in DLL 'ieframe.dll'. at Predicere.Utilities.LoginUtils.IEGetProtectedModeCookie(String url, String cookieName, StringBuilder cookieData, Int32& size, UInt32 flag) at Predicere.Utilities.LoginUtils.GetProtectedModeIECookieValue(String cookieName, Boolean isFacebookPage) in blah...

What am I missing here?


Solution

  • So, we finally found a solution using feedback from S.O. on another separate but related issue.

    The problem is that IEGetProtectedModeCookie was not introduced until IE8, but the baseline Azure web instance is based on IE7.

    The OS flavor is controlled by the osFamily attrib in :

    <ServiceConfiguration serviceName="Foobar" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="1" osVersion="*">
    

    This setting installs Windows Server 2008 SP2, which is based on IE7.

    If we modify the osFamily attrib as follows, we end up with Windows Server 2008 R2, which is based on IE8:

    <ServiceConfiguration serviceName="Foobar" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="2" osVersion="*">
    

    More details can be found in this blog entry, especially if you want to upgrade you Azure instance to use IE9 (which, it turns out, is non-trivial).

    http://sajojacob.com/blog/2011/03/startup-tasks-elevated-privileges-vm-role/