January 17, 2008

Notes for writing DLL in which use STL objects

You may experience an access violation when you access an STL object through a pointer or reference in a different DLL or EXE.

Root Cause:
Since the static data members in the executable images are not in sync, this action could result in an access violation or data may appear to be lost or corrupted.

Suggestion:
Avoid using STL object as the parameter or the return value of an exported DLL function.

MSDN Reference: