I am trying use CLR from an old VC6 MFC app that was ported to the VC7
compiler. Initially the app worked fine. However, after I enabled /clr in
the project
settings and ran the app, all calls to AfxOleInit(), OleInitialize() and
Coinitialize() fail with hr=0x80010106. Error lookup shows this error as:
"Cannot change thread mode after it is set."
It seems to me that this error could only occur if a thread mode were alreay
set. Therefore the CLR must have already called CoInitializeEx() with
COINIT_MULTITHREADED by the time my MFC app got around to calling
AfxOleInit(). So I tried commenting out my app's call to AfxOleInit(). Then
the app failed the same way in other spots. For instance, the app uses DAO
which apparently calls CoInitialize() from line 5665 in daocore.cpp.
Commenting out OLE/COM inititialization calls does not seem the correct way
to fix this problem. I can't and don't want to modify daocore.cpp.
Is there any other way to resolve this problem? Perhaps some way to
instruct the CLR to COINIT_APARTMENTTHREADED? Can anyone help?
Your help would be much appreciated.

Signature
Regards,
-Ron
RNEELY - 03 Dec 2004 16:55 GMT
This thread was resolved via code guru
http://www.codeproject.com/script/comments/forums.asp?forumid=3785&df=4&mpp=50&s
elect=987044&msg=987044#xx987044xx