I had hard couple days in resolving an issue related with initialization of MAPI session in child thread from .NET application. I tried bunch of situations but the result was same:
I got the error saying me that CDO cannot me initialized.
System.Runtime.InteropServices.COMException was caught
ErrorCode=-2147417850
Message="Retrieving the COM class factory for component with CLSID {3FA7DEB3-6438-101B-ACC1-00AA00423326} failed due to the following error: 80010106."
Source="TSCGContactSearch"
StackTrace:
at TSCGContactSearch.OutlookSearch.fGetOutlookSession(Object& olretNameSpace, Object& olretApp, Session& cdoretMapiSession) in D:\Projects\SCS\dotNet\ContactSearch\TSCGContactSearch\OutlookSearch.vb:line 614
I read in forums but still .. nothing...
I found this article form Stephen Griffin
http://blogs.msdn.com/stephen_griffin/archive/2004/09/24/233985.aspx
I tried to call MAPIInitialization from child thred .. but still I get this anoying error.
Finally I came accross an article on MSDN in italian that gave me the idea to change ThreadingModel key in registry (under MAPI.Session's GUID) from "Both" to "Appartment" and ... here we go. No more errors. My application runs.
HKEY_CLASSES_ROOT\CLSID\{3FA7DEB3-6438-101B-ACC1-00AA00423326}\InprocServer32\ThreadingModel
this was strange error as application was fine when was compiled under .NET 1.1 but .NET 2.0 breaks it. Very strange...