• Sign in
 
  •  
  • MSDN Blogs
  • Microsoft Blog Images
  • More ...

  • Blog Home
  • About
  • Email Blog Author
  • Share this
  • RSS for posts
  • Atom
  • RSS for comments
  • CDO (25)
  • Code Snippet (43)
  • Custom Providers (17)
  • Debugging (7)
  • DevMsgTeam (301)
  • Documentation (109)
  • DST (8)
  • EWS (7)
  • Exchange (109)
  • Gotchas (97)
  • Hotfix (28)
  • MAPI (240)
  • MAPI Download (54)
  • MFCMAPI (101)
  • MSDN (59)
  • Non Dev (11)
  • OOM (17)
  • Outlook (171)
  • Outlook 2007 Auxiliary Reference (45)
  • Outlook Integration API (12)
  • Protocol Docs (20)
  • PST/OST (23)
  • Referrals (8)
  • Vista (12)
  • WrapPST (18)
Links:
  • Download MFCMAPI
  • MFCMAPI on Facebook
  • Troubleshooting Outlook Crashes
  • Office Update Center
  • Developer Messaging Team Blog
This site is provided "AS IS" with no warranties, and confers no rights. Use of included code samples are subject to the terms specified in the Terms of Use.
Archives
  • May 2013 (3)
  • April 2013 (1)
  • March 2013 (2)
  • February 2013 (2)
  • January 2013 (2)
  • December 2012 (4)
  • November 2012 (2)
  • October 2012 (2)
  • September 2012 (1)
  • August 2012 (3)
  • June 2012 (2)
  • May 2012 (1)
  • April 2012 (3)
  • March 2012 (3)
  • February 2012 (3)
  • January 2012 (1)
  • December 2011 (3)
  • November 2011 (1)
  • October 2011 (3)
  • September 2011 (1)
  • August 2011 (1)
  • July 2011 (4)
  • June 2011 (3)
  • May 2011 (3)
  • April 2011 (3)
  • March 2011 (5)
  • February 2011 (1)
  • January 2011 (2)
  • December 2010 (1)
  • November 2010 (4)
  • October 2010 (1)
  • September 2010 (3)
  • August 2010 (5)
  • July 2010 (3)
  • June 2010 (3)
  • May 2010 (1)
  • April 2010 (3)
  • March 2010 (3)
  • February 2010 (3)
  • January 2010 (2)
  • December 2009 (3)
  • November 2009 (5)
  • October 2009 (4)
  • September 2009 (5)
  • August 2009 (5)
  • July 2009 (11)
  • June 2009 (6)
  • May 2009 (5)
  • April 2009 (3)
  • March 2009 (18)
  • February 2009 (10)
  • January 2009 (3)
  • December 2008 (2)
  • November 2008 (2)
  • October 2008 (5)
  • September 2008 (4)
  • August 2008 (10)
  • July 2008 (6)
  • June 2008 (8)
  • May 2008 (2)
  • April 2008 (4)
  • March 2008 (2)
  • February 2008 (2)
  • January 2008 (5)
  • December 2007 (3)
  • November 2007 (2)
  • October 2007 (3)
  • September 2007 (1)
  • August 2007 (4)
  • July 2007 (5)
  • June 2007 (3)
  • May 2007 (4)
  • April 2007 (1)
  • March 2007 (6)
  • February 2007 (3)
  • January 2007 (2)
  • December 2006 (4)
  • November 2006 (3)
  • October 2006 (1)
  • August 2006 (1)
  • June 2006 (5)
  • May 2006 (5)
  • December 2005 (1)
  • November 2005 (4)
  • October 2005 (2)
  • September 2005 (1)
  • April 2005 (3)
  • December 2004 (2)
  • September 2004 (2)
  • August 2004 (3)
  • July 2004 (3)

Remote Typelibs and the Outlook Object Model

MSDN Blogs > SGriffin's MAPI Internals > Remote Typelibs and the Outlook Object Model

Remote Typelibs and the Outlook Object Model

Stephen Griffin - MSFT
2 Jul 2010 8:17 AM
  • Comments 2

As I’ve mentioned before, I don’t like to install Office on my build servers. Neither do some of my customers, one of whom reported that they couldn’t get their Outlook 2010 based object model code to compile on their build servers.

The problem they reported was in their #import statements. They looked something like this:

#import "\\RemoteMachine\c$\Program Files (x86)\Common Files\Microsoft Shared\Office14\MSO.DLL" rename_namespace("OL")
#import "\\RemoteMachine\c$\Program Files (x86)\Microsoft Office\OFFICE14\msoutl.olb" rename_namespace("OL") rename ("GetOrganizer", "GetOrganizer1")

Note that they’re pointing the compiler at binaries installed on another machine to #import from. When they pointed these at Outlook 2007’s type libraries, the #import was successful. But when they pointed it at Outlook 2010’s type libraries, they got this:

error C4772: #import referenced a type from a missing type library; '__missing_type__' used as a placeholder

Now – we quickly discovered that despite this error, the compiler still produced .tli and .tlh files for both mso and msoutl, so subsequent compilations worked, and we could ignore the error with #pragma warning(disable:4772), but this didn’t feel like a satisfactory solution. The compilations only succeeded because they weren’t using anything out of the type library which had __missing_type__ on it, so as their development continued, they were likely to hit a roadblock.

The question then was why the C4772 error happened in the first place. We look at the documentation for the error, which states:

“However, the type library contained a reference to another type library that was not referenced with #import...If you want the compiler to find type libraries in different directories, add those directories to the PATH environment variable”

So some dependency wasn’t found for one of our type libraries. Experimentation showed that mso.dll imported without error and msoutl.olb was the one having a problem. We used Procmon during compilation and saw that, right after the compiler started looking at msoutl.olb, it went crazy trying to find a copy of mso.dll. It looked in every directory on the path. This is consistent with what we saw in the documentation for C4772, so we tried placing a copy of mso.dll in one of the directories on the path. Success! Everything compiled just fine.

I still wasn’t satisfied that we had a resolution though, since a check on a machine with Outlook installed showed that mso.dll wasn’t on the path their either, yet compilation succeeded. And then there was the report that Outlook 2007 type libraries did not exhibit this problem. So we ran Procmon on the machine with Outlook installed and watched what happened during compilation. ProcMon showed that while we were processing msoutl.olb, we did find mso.dll. We found it by looking in the registry under typelibs, specifically, under this key:

HKEY_CLASSES_ROOT\TypeLib\{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}\2.5

Now things were starting to clear up. During the installation of Office, one of the things the installer did was register a version of mso.dll under the TypeLib key. This registration is what allowed the compiler to find a copy of mso.dll while it was processing msoutl.olb. Returning to the build server, we found that while we did not have this 2.5 subkey, we did have a 2.4 subkey which pointed to a copy of Outlook 2007’s version of mso.dll which happened to be on the server, presumably installed by some other product which had a dependency on mso.dll.

This, then, is our resolution – if we want the compiler to handle type libraries which have a dependency on a specific version of mso.dll, we need to register that version under the TypeLib key. The simple way to do this is to export the key from a machine where Outlook is installed, then import it on the build server after correcting the path. Here’s what mine looked like:

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\TypeLib\{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}]
[HKEY_CLASSES_ROOT\TypeLib\{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}\2.5]
"PrimaryInteropAssemblyName"="Office, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"
@="Microsoft Office 14.0 Object Library"
[HKEY_CLASSES_ROOT\TypeLib\{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}\2.5\0]
[HKEY_CLASSES_ROOT\TypeLib\{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}\2.5\0\win32]
@="\\\\RemoteMachine\\c$\\Program Files (x86)\\Common Files\\Microsoft Shared\\Office14\\MSO.DLL"
[HKEY_CLASSES_ROOT\TypeLib\{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}\2.5\FLAGS]
@="0"

Once this bit of type library magic was put in place, we were able to compile without error.

BTW – some interesting reading on type libraries that I found useful in figuring this out:

http://blogs.msdn.com/b/larryosterman/archive/2006/01/09/510856.aspx

http://msdn.microsoft.com/en-us/library/ms221610(VS.71).aspx

http://msdn.microsoft.com/en-us/library/ms221570(VS.71).aspx

Enjoy!

  • 2 Comments
Outlook, Gotchas, OOM, DevMsgTeam
Comments
  • Lev
    6 Jul 2010 8:00 PM

    cool debugging tips - thanks.  Why not generate .tlh & .tli ( on the machine with Outlook installed ) and include them as dependencies?  This way the build machine does not have to worry about the environment ( remote or local ) at all.

  • Stephen Griffin - MSFT
    7 Jul 2010 6:34 AM

    I thought about that, but there was something about it that wasn't working, so I didn't pursue it. I should probably look at it again.

Page 1 of 1 (2 items)
Leave a Comment
  • Please add 5 and 3 and type the answer here:
  • Post
  • © 2013 Microsoft Corporation.
  • Terms of Use
  • Trademarks
  • Privacy & Cookies
  • Report Abuse
  • 5.6.426.415