MAPILogonEx causes crash if Version Info is not specified on the module
I wanted to create a simple Extended MAPI application that would call MAPIInitialize() followed by MAPILogonEx() . Seems simple right? I do it all the time. However, this time, for whatever reason, every time I called MAPILogonEx() my process crashed. No matter what flags I chose, or how I called either MAPIInitialize() or MAPILogonEx() , it would crash. I was perplexed. I've written ton of MAPI code and never got an error like this. After debugging it I realized that Office¹ requires that the application include file version information. If the path to the application is too long or the application doesn't have file version information, Office¹ will force a crash of the application. I believe it does this for the Help. Here are some ways you can recognize this problem. First, you'll see a stack similar to this in Visual Studio:
kb Index Function -------------------------------------------------------------------------------- 1 Mso98win32client.dll!6d08313b() 2 [Frames below may be incorrect and/or missing, no symbols loaded for Mso98win32client.dll] 3 Mso98win32client.dll!6d07c374() 4 vcruntime140.dll!7400d627() 5 vcruntime140.dll!7400e882() 6 vcruntime140.dll!740036e8() 7 vcruntime140.dll!74003654() 8 vcruntime140.dll!74003215() 9 vcruntime140.dll!74002f88() 10 vcruntime140.dll!7400ec26() 11 ntdll.dll!77d3b652() 12 ntdll.dll!77d3b624() 13 ntdll.dll!77d1420b() 14 ntdll.dll!77d28e7f() 15 KernelBase.dll!766802c5() 16 KernelBase.dll!76695468() 17 vcruntime140.dll!740049a5() 18 Mso98win32client.dll!6d07c4fe() 19 Mso98win32client.dll!6d02b65a() 20 OLMAPI32.DLL!6f53a7b0() 21 Mso20win32client.dll!6f2eee84() 22 Mso20win32client.dll!6f2eec62() 23 Mso20win32client.dll!6f2ece9c() 24 Mso20win32client.dll!6f2f40f5() 25 OLMAPI32.DLL!6f5393db() 26 OLMAPI32.DLL!6f5393bd() 27 OLMAPI32.DLL!6f54e8bb() 28 OLMAPI32.DLL!6f54dd36() 29 OLMAPI32.DLL!6f54cb9b() 30 OLMAPI32.DLL!6f5446a5() 31 OLMAPI32.DLL!6f543eff() 32 MSMAPI32.DLL!51974e3d() *33 YourAppHere.exe!MAPILogonEx(unsigned long a=0x00000000, wchar_t * b=0x00000000, wchar_t * c=0x00000000, unsigned long d=0x0000003b, IMAPISession * * e=0x0286f870) 34 YourAppHere.exe!WorkerThread(void * state=0x008ff74c) 35 msvcr120d.dll!5a2c3651() 36 msvcr120d.dll!5a2c3861() 37 kernel32.dll!772338f4() 38 ntdll.dll!77d15de3() 39 ntdll.dll!77d15dae()
and an error message that says Unhandled exception at 0x6D08313B (Mso98win32client.dll) in YourAppHere.exe: 0x0128300C (parameters: 0x00000001, 0x00000000).
Now, fixing this is easy if you know what to do. In Visual Studio, just add the resource type "Version" and fill in the various fields for your application. Next, Clean the solution, and Rebuild. I find that if I don't Clean and Rebuild, it doesn't fix the issue. That's it. After that it should work. This was a big blocker for me, but I suppose that for people building real world applications this won't be a problem since they'll have this included in their applications anyway. Only little test applications would be affected.
¹ I use this term rather than Outlook because this isn't Outlook's doing. This is "shared Office code" that causes this, not Outlook.