Q. I am using the Extensibility SDK with a COM object written in Perl for authentication. However I am getting Could not AfxOleInit (2) and RPC_E_CHANGED_MODE in the event log, and I cannot get access with a valid username password.
A. The Win32 implementation of Perl is initialized to COINIT_MULTITHREADED by default. However for robustness and security, the Extensibility SDK calls the COM object on a thread that is COINIT_APARTMENTTHREADED.
If you are using Perl for other applications on the same machine, then they will initialize Perl as multithread and the above conflict will occur.
Set Perl to initialize as COINIT_APARTMENTTHREADED to solve this problem.
Another thing to try: