Hi, It now i have been creating a managed wrapper for mapi32.dll in VC++.NET 2005. Then i was consuming the managed dll in my C#.application. Everything was working fine but as i wanted to deal with multiple PST at a time so i made the Application (C#) threaded. But no soon i called the API of my managed DLL in thread, MAPIInitialize(NULL) failed and returned the error code -2147417850. I am trying to initialize mapi inside thread, for each thread. What can be wrong:- My VC++ wrapper project has following properties: Common Language Runtime Support, Old Syntax (/clr:oldSyntax) Multi-threaded Debug DLL (/MDd) where am i wrong.. please help me Thank You miztaken
Hi miztaken, > It now i have been creating a managed wrapper for mapi32.dll in > VC++.NET 2005. > > Then i was consuming the managed dll in my C#.application. > > Everything was working fine but as i wanted to deal with multiple PST > at a time so i made the Application (C#) threaded. > But no soon i called the API of my managed DLL in thread, > MAPIInitialize(NULL) failed and returned the error code -2147417850. > > I am trying to initialize mapi inside thread, for each thread. Make sure you are creating STA threads, i.e. apartment threaded threads. Thread t = new Thread(...); t.ApartmentState = ApartmentState.STA; t.Start(); Call MAPIInitialize only once per thread at the beginning of the thread function. -- SvenC