I used the UNICODE preprocessor directive to support UNICODE, however, doing so causes bizarre crashes.

Code:
"Unhandled exception at 0x7c96478e (ntdll.dll) in OUTLOOK.EXE: 0xC000000D: An invalid parameter was passed to a service or function."
 
  ntdll.dll!_RtlRaiseStatus@4()  + 0x26 bytes 
  ntdll.dll!_RtlDeactivateActivationContext@8()  + 0x2b094 bytes 
  kernel32.dll!_DeactivateActCtx@8()  + 0x28 bytes 
  mfc80ud.dll!AfxDeactivateActCtx()  + 0x1d bytes 
  mfc80ud.dll!AFX_MAINTAIN_STATE2::~AFX_MAINTAIN_STATE2()  + 0x37 bytes
Is there something obvious that I'm doing wrong? I don't see why using the UNICODE directive causes this problem.

Looking at the stack trace I'm guessing that the problem has to do with this line of code:

Code:
AFX_MANAGE_STATE(AfxGetStaticModuleState())
The crash occurs when I'm exiting a function in my code.